summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-21 22:00:00 +0000
committerrubidium <rubidium@openttd.org>2009-03-21 22:00:00 +0000
commit900364109597f02413e2f7a59e9b4e6cc9fdf97f (patch)
tree308b7c3eda7e63a306620580ef4df5f4b99b893e
parentd452a0a0ecaad276c893b62ab8f008a5af85ba82 (diff)
downloadopenttd-900364109597f02413e2f7a59e9b4e6cc9fdf97f.tar.xz
(svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
-rw-r--r--src/company_gui.cpp6
-rw-r--r--src/engine_gui.cpp2
-rw-r--r--src/genworld_gui.cpp6
-rw-r--r--src/gfx.cpp51
-rw-r--r--src/gfx_func.h6
-rw-r--r--src/graph_gui.cpp6
-rw-r--r--src/music_gui.cpp26
-rw-r--r--src/network/network_content_gui.cpp8
-rw-r--r--src/network/network_gui.cpp26
-rw-r--r--src/news_gui.cpp12
-rw-r--r--src/rail_gui.cpp13
-rw-r--r--src/settings_gui.cpp4
-rw-r--r--src/station_gui.cpp7
-rw-r--r--src/statusbar_gui.cpp4
-rw-r--r--src/widget.cpp2
15 files changed, 60 insertions, 119 deletions
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 1d7187be9..3703e2b1f 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -92,7 +92,7 @@ static void DrawCompanyEconomyStats(const Company *c, bool small)
if (!small) { // normal sized economics window
/* draw categories */
- DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, TC_FROMSTRING);
+ DrawString(0, 122, 15, STR_700F_EXPENDITURE_INCOME, TC_FROMSTRING, SA_CENTER, true);
y = 27;
for (i = 0; i < _expenses_list_types[type].length; i++) {
@@ -832,8 +832,8 @@ class SelectCompanyManagerFaceWindow : public Window
}
/* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */
- DrawStringCentered(this->widget[widget_index].left + (this->widget[widget_index].right - this->widget[widget_index].left) / 2 +
- this->IsWidgetLowered(widget_index), this->widget[widget_index].top + 1 + this->IsWidgetLowered(widget_index), str, TC_WHITE);
+ DrawString(this->widget[widget_index].left + this->IsWidgetLowered(widget_index), this->widget[widget_index].right - this->IsWidgetLowered(widget_index),
+ this->widget[widget_index].top + 1 + this->IsWidgetLowered(widget_index), str, TC_WHITE, SA_CENTER);
}
}
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 91f7dd89a..75a41768a 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -83,7 +83,7 @@ struct EnginePreviewWindow : Window {
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296);
SetDParam(0, engine);
- DrawString(this->widget[EPW_BACKGROUND].left + 2, this->widget[EPW_BACKGROUND].right - 2, 80, STR_ENGINE_NAME, TC_BLACK);
+ DrawString(this->widget[EPW_BACKGROUND].left + 2, this->widget[EPW_BACKGROUND].right - 2, 80, STR_ENGINE_NAME, TC_BLACK, SA_CENTER);
const DrawEngineInfo *dei = &_draw_engine_list[GetEngine(engine)->type];
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 5163c0025..953d3b620 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -966,15 +966,15 @@ public:
DrawFrameRect(19, 20, (this->width - 18), 37, COLOUR_GREY, FR_BORDERONLY);
DrawFrameRect(20, 21, (int)((this->width - 40) * _tp.percent / 100) + 20, 36, COLOUR_MAUVE, FR_NONE);
SetDParam(0, _tp.percent);
- DrawStringCentered(90, 25, STR_PROGRESS, TC_FROMSTRING);
+ DrawString(this->widget[GPWW_BACKGROUND].left, this->widget[GPWW_BACKGROUND].right, 25, STR_PROGRESS, TC_FROMSTRING, SA_CENTER);
/* Tell which class we are generating */
- DrawStringCentered(90, 46, _tp.cls, TC_FROMSTRING);
+ DrawString(this->widget[GPWW_BACKGROUND].left, this->widget[GPWW_BACKGROUND].right, 46, _tp.cls, TC_FROMSTRING, SA_CENTER);
/* And say where we are in that class */
SetDParam(0, _tp.current);
SetDParam(1, _tp.total);
- DrawStringCentered(90, 58, STR_GENERATION_PROGRESS, TC_FROMSTRING);
+ DrawString(this->widget[GPWW_BACKGROUND].left, this->widget[GPWW_BACKGROUND].right, 58, STR_GENERATION_PROGRESS, TC_FROMSTRING, SA_CENTER);
this->SetDirty();
}
diff --git a/src/gfx.cpp b/src/gfx.cpp
index a65b30131..aef176151 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -424,7 +424,7 @@ static int DrawString(int left, int right, int top, char *str, const char *last,
break;
case SA_CENTER:
- left += (right - left - w) / 2;
+ left += (right - left - w + 1) / 2;
right = left + w;
break;
@@ -510,55 +510,6 @@ int DrawStringRightAlignedUnderline(int x, int y, StringID str, TextColour colou
}
/**
- * Draw string centered.
- *
- * @param x X position of center of the string
- * @param y Y position of center of the string
- * @param str String to draw
- * @param colour Colour used for drawing the string, see DoDrawString() for details
- */
-int DrawStringCentered(int x, int y, StringID str, TextColour colour)
-{
- char buffer[DRAW_STRING_BUFFER];
- GetString(buffer, str, lastof(buffer));
- int w = GetStringBoundingBox(buffer).width;
- return DrawString(x - w, x + w, y, buffer, lastof(buffer), colour, SA_CENTER);
-}
-
-/**
- * Draw string centered.
- *
- * @param x X position of center of the string
- * @param y Y position of center of the string
- * @param str String to draw
- * @param colour Colour used for drawing the string, see DoDrawString() for details
- */
-int DoDrawStringCentered(int x, int y, const char *str, TextColour colour)
-{
- char buffer[DRAW_STRING_BUFFER];
- strecpy(buffer, str, lastof(buffer));
-
- int w = GetStringBoundingBox(buffer).width;
- return DrawString(x - w, x + w, y, buffer, lastof(buffer), colour, SA_CENTER);
-}
-
-/**
- * Draw string centered, with additional line underneath it
- *
- * @param x X position of center of the string
- * @param y Y position of center of the string
- * @param str String to draw
- * @param colour Colour used for drawing the string, see DoDrawString() for details
- */
-int DrawStringCenterUnderline(int x, int y, StringID str, TextColour colour)
-{
- char buffer[DRAW_STRING_BUFFER];
- GetString(buffer, str, lastof(buffer));
- int w = GetStringBoundingBox(buffer).width;
- return DrawString(x - w, y + w, y, buffer, lastof(buffer), colour, SA_CENTER, true);
-}
-
-/**
* 'Correct' a string to a maximum length. Longer strings will be cut into
* additional lines at whitespace characters if possible. The string parameter
* is modified with terminating characters mid-string which are the
diff --git a/src/gfx_func.h b/src/gfx_func.h
index 1faa8dea8..43ac66491 100644
--- a/src/gfx_func.h
+++ b/src/gfx_func.h
@@ -95,15 +95,9 @@ enum StringAlignment {
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align = SA_LEFT, bool underline = false);
int DrawString(int left, int right, int top, StringID str, TextColour colour, StringAlignment align = SA_LEFT, bool underline = false);
-int DrawStringCentered(int x, int y, StringID str, TextColour colour);
-int DoDrawStringCentered(int x, int y, const char *str, TextColour colour);
-
int DrawString(int x, int y, StringID str, TextColour colour);
-
int DoDrawString(const char *string, int x, int y, TextColour colour, bool parse_string_also_when_clipped = false);
-int DrawStringCenterUnderline(int x, int y, StringID str, TextColour colour);
-
int DrawStringRightAligned(int x, int y, StringID str, TextColour colour);
int DrawStringRightAlignedUnderline(int x, int y, StringID str, TextColour colour);
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 44cfe75ec..3429fb409 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -275,13 +275,13 @@ protected:
}
} else {
/* Draw the label under the data point rather than on the grid line. */
- x = this->gd_left + GRAPH_X_POSITION_BEGINNING + (GRAPH_X_POSITION_SEPARATION / 2) + 1;
+ x = this->gd_left + GRAPH_X_POSITION_BEGINNING;
y = this->gd_top + this->gd_height + 1;
uint16 label = this->x_values_start;
for (int i = 0; i < this->num_on_x_axis; i++) {
SetDParam(0, label);
- DrawStringCentered(x, y, STR_01CB, graph_axis_label_colour);
+ DrawString(x + 1, x + GRAPH_X_POSITION_SEPARATION - 1, y, STR_01CB, graph_axis_label_colour, SA_CENTER);
label += this->x_values_increment;
x += GRAPH_X_POSITION_SEPARATION;
@@ -1002,7 +1002,7 @@ public:
/* Draw it */
SetDParam(0, x);
- DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING);
+ DrawString(112, 162, y, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING, SA_CENTER);
/* SCORE_LOAN is inversed */
if (i == SCORE_LOAN) val = needed - val;
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index 44dde7e0b..e79c51c5b 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -230,10 +230,10 @@ public:
GfxFillRect( 3, 23, 3 + 177, 23 + 191, 0);
GfxFillRect(251, 23, 251 + 177, 23 + 191, 0);
- DrawStringCentered(92, 15, STR_01EE_TRACK_INDEX, TC_FROMSTRING);
+ DrawString(this->widget[MTSW_LIST_LEFT].left + 2, this->widget[MTSW_LIST_LEFT].right - 2, 15, STR_01EE_TRACK_INDEX, TC_FROMSTRING, SA_CENTER);
SetDParam(0, STR_01D5_ALL + msf.playlist);
- DrawStringCentered(340, 15, STR_01EF_PROGRAM, TC_FROMSTRING);
+ DrawString(this->widget[MTSW_LIST_RIGHT].left + 2, this->widget[MTSW_LIST_RIGHT].right - 2, 15, STR_01EF_PROGRAM, TC_FROMSTRING, SA_CENTER);
for (i = 1; i <= NUM_SONGS_AVAILABLE; i++) {
SetDParam(0, i);
@@ -243,12 +243,12 @@ public:
}
for (i = 0; i != 6; i++) {
- DrawStringCentered(216, 45 + i * 8, STR_01D5_ALL + i, (i == msf.playlist) ? TC_WHITE : TC_BLACK);
+ DrawString(this->widget[MTSW_ALL].left + 2, this->widget[MTSW_ALL].right - 2, 45 + i * 8, STR_01D5_ALL + i, (i == msf.playlist) ? TC_WHITE : TC_BLACK, SA_CENTER);
}
- DrawStringCentered(216, 45 + 8 * 6 + 16, STR_01F0_CLEAR, TC_FROMSTRING);
+ DrawString(this->widget[MTSW_ALL].left + 2, this->widget[MTSW_ALL].right - 2, 45 + 8 * 6 + 16, STR_01F0_CLEAR, TC_FROMSTRING, SA_CENTER);
#if 0
- DrawStringCentered(216, 45 + 8 * 6 + 16 * 2, STR_01F1_SAVE, TC_FROMSTRING);
+ DrawString(this->widget[MTSW_SAVE].left + 2, this->widget[MTSW_SAVE].right - 2, 45 + 8 * 6 + 16 * 2, STR_01F1_SAVE, TC_FROMSTRING, SA_CENTER);
#endif
y = 23;
@@ -424,21 +424,21 @@ public:
SetDParam(0, SPECSTR_SONGNAME);
SetDParam(1, _music_wnd_cursong);
}
- DrawStringCentered(155, 46, str, TC_FROMSTRING);
+ DrawString(this->widget[MW_INFO].left, this->widget[MW_INFO].right, 46, str, TC_FROMSTRING, SA_CENTER);
DrawString(60, 38, STR_01E8_TRACK_XTITLE, TC_FROMSTRING);
for (i = 0; i != 6; i++) {
- DrawStringCentered(25 + i * 50, 59, STR_01D5_ALL + i, msf.playlist == i ? TC_WHITE : TC_BLACK);
+ DrawString(this->widget[i + MW_ALL].left, this->widget[i + MW_ALL].right, 59, STR_01D5_ALL + i, msf.playlist == i ? TC_WHITE : TC_BLACK, SA_CENTER);
}
- DrawStringCentered( 31, 43, STR_01E9_SHUFFLE, (msf.shuffle ? TC_WHITE : TC_BLACK));
- DrawStringCentered(269, 43, STR_01EA_PROGRAM, TC_FROMSTRING);
- DrawStringCentered(141, 15, STR_01DB_MUSIC_VOLUME, TC_FROMSTRING);
- DrawStringCentered(141, 29, STR_01DD_MIN_MAX, TC_FROMSTRING);
- DrawStringCentered(247, 15, STR_01DC_EFFECTS_VOLUME, TC_FROMSTRING);
- DrawStringCentered(247, 29, STR_01DD_MIN_MAX, TC_FROMSTRING);
+ DrawString(this->widget[MW_NEXT].left, this->widget[MW_NEXT].right, 43, STR_01E9_SHUFFLE, (msf.shuffle ? TC_WHITE : TC_BLACK), SA_CENTER);
+ DrawString(this->widget[MW_PROGRAMME].left, this->widget[MW_PROGRAMME].right, 43, STR_01EA_PROGRAM, TC_FROMSTRING, SA_CENTER);
+ DrawString(108, 174, 15, STR_01DB_MUSIC_VOLUME, TC_FROMSTRING, SA_CENTER);
+ DrawString(108, 174, 29, STR_01DD_MIN_MAX, TC_FROMSTRING, SA_CENTER);
+ DrawString(214, 280, 15, STR_01DC_EFFECTS_VOLUME, TC_FROMSTRING, SA_CENTER);
+ DrawString(214, 280, 29, STR_01DD_MIN_MAX, TC_FROMSTRING, SA_CENTER);
DrawFrameRect(108, 23, 174, 26, COLOUR_GREY, FR_LOWERED);
DrawFrameRect(214, 23, 280, 26, COLOUR_GREY, FR_LOWERED);
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 081674a9c..f70502f9c 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -128,17 +128,17 @@ public:
SetDParam(0, this->downloaded_bytes);
SetDParam(1, this->total_bytes);
SetDParam(2, this->downloaded_bytes * 100 / this->total_bytes);
- DrawStringCentered(this->width / 2, 35, STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_GREY);
+ DrawString(this->widget[NCDSWW_BACKGROUND].left + 2, this->widget[NCDSWW_BACKGROUND].right - 2, 35, STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_GREY, SA_CENTER);
if (this->downloaded_bytes == this->total_bytes) {
- DrawStringCentered(this->width / 2, 50, STR_CONTENT_DOWNLOAD_COMPLETE, TC_GREY);
+ DrawString(this->widget[NCDSWW_BACKGROUND].left + 2, this->widget[NCDSWW_BACKGROUND].right - 2, 50, STR_CONTENT_DOWNLOAD_COMPLETE, TC_GREY, SA_CENTER);
} else if (!StrEmpty(this->name)) {
SetDParamStr(0, this->name);
SetDParam(1, this->downloaded_files);
SetDParam(2, this->total_files);
DrawStringMultiCenter(this->width / 2, 50, STR_CONTENT_DOWNLOAD_FILE, this->width);
} else {
- DrawStringCentered(this->width / 2, 50, STR_CONTENT_DOWNLOAD_INITIALISE, TC_GREY);
+ DrawString(this->widget[NCDSWW_BACKGROUND].left + 2, this->widget[NCDSWW_BACKGROUND].right - 2, 50, STR_CONTENT_DOWNLOAD_INITIALISE, TC_GREY, SA_CENTER);
}
}
@@ -430,7 +430,7 @@ public:
/* Create the nice grayish rectangle at the details top */
GfxFillRect(this->widget[NCLWW_DETAILS].left + 1, this->widget[NCLWW_DETAILS].top + 1, this->widget[NCLWW_DETAILS].right - 1, this->widget[NCLWW_DETAILS].top + 50, 157);
- DrawStringCentered((this->widget[NCLWW_DETAILS].left + this->widget[NCLWW_DETAILS].right) / 2, this->widget[NCLWW_DETAILS].top + 11, STR_CONTENT_DETAIL_TITLE, TC_FROMSTRING);
+ DrawString(this->widget[NCLWW_DETAILS].left + 2, this->widget[NCLWW_DETAILS].right - 2, this->widget[NCLWW_DETAILS].top + 11, STR_CONTENT_DETAIL_TITLE, TC_FROMSTRING, SA_CENTER);
if (this->selected == NULL) return;
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index d5e2cdbc2..ef4548472 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -248,13 +248,13 @@ protected:
SetDParam(1, cur_item->info.clients_max);
SetDParam(2, cur_item->info.companies_on);
SetDParam(3, cur_item->info.companies_max);
- DrawStringCentered(this->widget[NGWW_CLIENTS].left + 39, y, STR_NETWORK_GENERAL_ONLINE, TC_GOLD);
+ DrawString(this->widget[NGWW_CLIENTS].left, this->widget[NGWW_CLIENTS].right, y, STR_NETWORK_GENERAL_ONLINE, TC_GOLD, SA_CENTER);
/* map size */
if (!this->IsWidgetHidden(NGWW_MAPSIZE)) {
SetDParam(0, cur_item->info.map_width);
SetDParam(1, cur_item->info.map_height);
- DrawStringCentered(this->widget[NGWW_MAPSIZE].left + 39, y, STR_NETWORK_MAP_SIZE_SHORT, TC_BLACK);
+ DrawString(this->widget[NGWW_MAPSIZE].left, this->widget[NGWW_MAPSIZE].right, y, STR_NETWORK_MAP_SIZE_SHORT, TC_BLACK, SA_CENTER);
}
/* current date */
@@ -262,7 +262,7 @@ protected:
YearMonthDay ymd;
ConvertDateToYMD(cur_item->info.game_date, &ymd);
SetDParam(0, ymd.year);
- DrawStringCentered(this->widget[NGWW_DATE].left + 29, y, STR_JUST_INT, TC_BLACK);
+ DrawString(this->widget[NGWW_DATE].left, this->widget[NGWW_DATE].right, y, STR_JUST_INT, TC_BLACK, SA_CENTER);
}
/* number of years the game is running */
@@ -271,7 +271,7 @@ protected:
ConvertDateToYMD(cur_item->info.game_date, &ymd_cur);
ConvertDateToYMD(cur_item->info.start_date, &ymd_start);
SetDParam(0, ymd_cur.year - ymd_start.year);
- DrawStringCentered(this->widget[NGWW_YEARS].left + 29, y, STR_JUST_INT, TC_BLACK);
+ DrawString(this->widget[NGWW_YEARS].left, this->widget[NGWW_YEARS].right, y, STR_JUST_INT, TC_BLACK, SA_CENTER);
}
/* draw a lock if the server is password protected */
@@ -394,17 +394,17 @@ public:
/* Draw the right menu */
GfxFillRect(this->widget[NGWW_DETAILS].left + 1, 43, this->widget[NGWW_DETAILS].right - 1, 92, 157);
if (sel == NULL) {
- DrawStringCentered(this->widget[NGWW_DETAILS].left + 115, 58, STR_NETWORK_GAME_INFO, TC_FROMSTRING);
+ DrawString(this->widget[NGWW_DETAILS].left + 1, this->widget[NGWW_DETAILS].right - 1, 58, STR_NETWORK_GAME_INFO, TC_FROMSTRING, SA_CENTER);
} else if (!sel->online) {
SetDParamStr(0, sel->info.server_name);
- DrawStringCentered(this->widget[NGWW_DETAILS].left + 115, 68, STR_JUST_RAW_STRING, TC_ORANGE); // game name
+ DrawString(this->widget[NGWW_DETAILS].left + 1, this->widget[NGWW_DETAILS].right - 1, 68, STR_JUST_RAW_STRING, TC_ORANGE, SA_CENTER); // game name
- DrawStringCentered(this->widget[NGWW_DETAILS].left + 115, 132, STR_NETWORK_SERVER_OFFLINE, TC_FROMSTRING); // server offline
+ DrawString(this->widget[NGWW_DETAILS].left + 1, this->widget[NGWW_DETAILS].right - 1, 132, STR_NETWORK_SERVER_OFFLINE, TC_FROMSTRING, SA_CENTER); // server offline
} else { // show game info
uint16 y = 100;
const uint16 x = this->widget[NGWW_DETAILS].left + 5;
- DrawStringCentered(this->widget[NGWW_DETAILS].left + 115, 48, STR_NETWORK_GAME_INFO, TC_FROMSTRING);
+ DrawString(this->widget[NGWW_DETAILS].left + 1, this->widget[NGWW_DETAILS].right - 1, 48, STR_NETWORK_GAME_INFO, TC_FROMSTRING, SA_CENTER);
SetDParamStr(0, sel->info.server_name);
@@ -453,12 +453,12 @@ public:
y += 2;
if (!sel->info.compatible) {
- DrawStringCentered(this->widget[NGWW_DETAILS].left + 115, y, sel->info.version_compatible ? STR_NETWORK_GRF_MISMATCH : STR_NETWORK_VERSION_MISMATCH, TC_FROMSTRING); // server mismatch
+ DrawString(this->widget[NGWW_DETAILS].left + 1, this->widget[NGWW_DETAILS].right - 1, y, sel->info.version_compatible ? STR_NETWORK_GRF_MISMATCH : STR_NETWORK_VERSION_MISMATCH, TC_FROMSTRING, SA_CENTER); // server mismatch
} else if (sel->info.clients_on == sel->info.clients_max) {
/* Show: server full, when clients_on == max_clients */
- DrawStringCentered(this->widget[NGWW_DETAILS].left + 115, y, STR_NETWORK_SERVER_FULL, TC_FROMSTRING); // server full
+ DrawString(this->widget[NGWW_DETAILS].left + 1, this->widget[NGWW_DETAILS].right - 1, y, STR_NETWORK_SERVER_FULL, TC_FROMSTRING, SA_CENTER); // server full
} else if (sel->info.use_password) {
- DrawStringCentered(this->widget[NGWW_DETAILS].left + 115, y, STR_NETWORK_PASSWORD, TC_FROMSTRING); // password warning
+ DrawString(this->widget[NGWW_DETAILS].left + 1, this->widget[NGWW_DETAILS].right - 1, y, STR_NETWORK_PASSWORD, TC_FROMSTRING, SA_CENTER); // password warning
}
y += 10;
@@ -1229,9 +1229,9 @@ struct NetworkLobbyWindow : public Window {
/* Draw info about selected company when it is selected in the left window */
GfxFillRect(174, 39, 403, 75, 157);
- DrawStringCentered(290, 50, STR_NETWORK_COMPANY_INFO, TC_FROMSTRING);
+ DrawString(this->widget[NLWW_DETAILS].left + 10, this->widget[NLWW_DETAILS].right - 10, 50, STR_NETWORK_COMPANY_INFO, TC_FROMSTRING, SA_CENTER);
if (this->company != INVALID_COMPANY && !StrEmpty(this->company_info[this->company].company_name)) {
- const uint x = 183;
+ const uint x = this->widget[NLWW_DETAILS].left + 10;
y = 80;
SetDParam(0, gi->clients_on);
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index eb81caa7f..1755f03dc 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -57,7 +57,7 @@ static void DrawNewsBankrupcy(Window *w, const NewsItem *ni)
switch (ni->subtype) {
case NS_COMPANY_TROUBLE:
- DrawStringCentered(w->width >> 1, 1, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE, TC_FROMSTRING);
+ DrawString(0, w->width, 1, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE, TC_FROMSTRING, SA_CENTER);
SetDParam(0, ni->params[2]);
@@ -69,7 +69,7 @@ static void DrawNewsBankrupcy(Window *w, const NewsItem *ni)
break;
case NS_COMPANY_MERGER:
- DrawStringCentered(w->width >> 1, 1, STR_7059_TRANSPORT_COMPANY_MERGER, TC_FROMSTRING);
+ DrawString(0, w->width, 1, STR_7059_TRANSPORT_COMPANY_MERGER, TC_FROMSTRING, SA_CENTER);
SetDParam(0, ni->params[2]);
SetDParam(1, ni->params[3]);
SetDParam(2, ni->params[4]);
@@ -81,7 +81,7 @@ static void DrawNewsBankrupcy(Window *w, const NewsItem *ni)
break;
case NS_COMPANY_BANKRUPT:
- DrawStringCentered(w->width >> 1, 1, STR_705C_BANKRUPT, TC_FROMSTRING);
+ DrawString(0, w->width, 1, STR_705C_BANKRUPT, TC_FROMSTRING, SA_CENTER);
SetDParam(0, ni->params[2]);
DrawStringMultiCenter(
((w->width - 101) >> 1) + 98,
@@ -91,7 +91,7 @@ static void DrawNewsBankrupcy(Window *w, const NewsItem *ni)
break;
case NS_COMPANY_NEW:
- DrawStringCentered(w->width >> 1, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, TC_FROMSTRING);
+ DrawString(0, w->width, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, TC_FROMSTRING, SA_CENTER);
SetDParam(0, ni->params[2]);
SetDParam(1, ni->params[3]);
DrawStringMultiCenter(
@@ -842,9 +842,7 @@ struct MessageOptionsWindow : Window {
/* Draw the string of each setting on each button. */
for (int i = 0, y = 26; i < NT_END; i++, y += 12) {
- /* 51 comes from 13 + 89 (left and right of the button)+1, shiefted by one as to get division,
- * which will give centered position */
- DrawStringCentered(51, y + 1, _message_opt[_news_type_data[i].display], TC_BLACK);
+ DrawString(this->widget[WIDGET_NEWSOPT_START_OPTION + 1].left, this->widget[WIDGET_NEWSOPT_START_OPTION + 1].right, y + 1, _message_opt[_news_type_data[i].display], TC_BLACK, SA_CENTER);
}
}
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 484dd733b..0035ca9d7 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1054,10 +1054,10 @@ public:
_cur_dpi = old_dpi;
}
- DrawStringCentered(74, 15 + y_offset, STR_3002_ORIENTATION, TC_FROMSTRING);
- DrawStringCentered(74, 76 + y_offset, STR_3003_NUMBER_OF_TRACKS, TC_FROMSTRING);
- DrawStringCentered(74, 101 + y_offset, STR_3004_PLATFORM_LENGTH, TC_FROMSTRING);
- DrawStringCentered(74, 141 + y_offset, STR_3066_COVERAGE_AREA_HIGHLIGHT, TC_FROMSTRING);
+ DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 15 + y_offset, STR_3002_ORIENTATION, TC_FROMSTRING, SA_CENTER);
+ DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 76 + y_offset, STR_3003_NUMBER_OF_TRACKS, TC_FROMSTRING, SA_CENTER);
+ DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 101 + y_offset, STR_3004_PLATFORM_LENGTH, TC_FROMSTRING, SA_CENTER);
+ DrawString(this->widget[BRSW_PLATFORM_LEN_1].left, this->widget[BRSW_PLATFORM_LEN_7].right, 141 + y_offset, STR_3066_COVERAGE_AREA_HIGHLIGHT, TC_FROMSTRING, SA_CENTER);
int text_end = DrawStationCoverageAreaText(2, 166 + y_offset, SCT_ALL, rad, false);
text_end = DrawStationCoverageAreaText(2, text_end + 4, SCT_ALL, rad, true) + 4;
@@ -1432,9 +1432,8 @@ public:
/* Draw dragging signal density value in the BSW_DRAG_SIGNALS_DENSITY widget */
SetDParam(0, _settings_client.gui.drag_signals_density);
- DrawStringCentered(this->widget[BSW_DRAG_SIGNALS_DENSITY].left + (this->widget[BSW_DRAG_SIGNALS_DENSITY].right -
- this->widget[BSW_DRAG_SIGNALS_DENSITY].left) / 2 + 1,
- this->widget[BSW_DRAG_SIGNALS_DENSITY].top + 2, STR_JUST_INT, TC_ORANGE);
+ DrawString(this->widget[BSW_DRAG_SIGNALS_DENSITY].left, this->widget[BSW_DRAG_SIGNALS_DENSITY].right,
+ this->widget[BSW_DRAG_SIGNALS_DENSITY].top + 2, STR_JUST_INT, TC_ORANGE, SA_CENTER);
}
virtual void OnClick(Point pt, int widget)
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 69e9e35d7..91a4ab728 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1458,8 +1458,8 @@ void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clic
DrawFrameRect(x, y + 1, x + 9, y + 9, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
DrawFrameRect(x + 10, y + 1, x + 19, y + 9, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
- DrawStringCentered(x + 5, y + 1, STR_6819, TC_FROMSTRING); // [<]
- DrawStringCentered(x + 15, y + 1, STR_681A, TC_FROMSTRING); // [>]
+ DrawString(x, x + 9, y + 1, STR_6819, TC_FROMSTRING, SA_CENTER); // [<]
+ DrawString(x + 10, x + 19, y + 1, STR_681A, TC_FROMSTRING, SA_CENTER); // [>]
/* Grey out the buttons that aren't clickable */
if (!clickable_left) {
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 565402649..ea35138cd 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -334,17 +334,16 @@ public:
cg_ofst = HasBit(this->cargo_filter, c) ? 2 : 1;
GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour);
- DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, TC_BLACK);
+ DrawString(x + cg_ofst, x + 12 + cg_ofst, y + cg_ofst, cs->abbrev, TC_BLACK, SA_CENTER);
x += 14;
i++;
}
- x += 6;
cg_ofst = this->IsWidgetLowered(SLW_NOCARGOWAITING) ? 2 : 1;
- DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, TC_BLACK);
+ DrawString(x + cg_ofst, x + cg_ofst + 12, y + cg_ofst, STR_ABBREV_NONE, TC_BLACK, SA_CENTER);
x += 14;
cg_ofst = this->IsWidgetLowered(SLW_CARGOALL) ? 2 : 1;
- DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
+ DrawString(x + cg_ofst, x + cg_ofst + 12, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_CENTER);
cg_ofst = this->IsWidgetLowered(SLW_FACILALL) ? 2 : 1;
DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp
index 286fc31ce..4849c7050 100644
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -97,12 +97,12 @@ struct StatusBarWindow : Window {
this->DrawWidgets();
SetDParam(0, _date);
- DrawStringCentered(70, 1, (_pause_game || _settings_client.gui.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING);
+ DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, (_pause_game || _settings_client.gui.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING, SA_CENTER);
if (c != NULL) {
/* Draw company money */
SetDParam(0, c->money);
- DrawStringCentered(this->widget[SBW_RIGHT].left + 70, 1, STR_0004, TC_FROMSTRING);
+ DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_0004, TC_FROMSTRING, SA_CENTER);
}
/* Draw status bar */
diff --git a/src/widget.cpp b/src/widget.cpp
index 088c6a7be..8fcca88ca 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -250,7 +250,7 @@ void Window::DrawWidgets() const
if ((wi->type & WWT_MASK) == WWT_TEXTBTN_2 && clicked) str++;
- DrawStringCentered(((r.left + r.right + 1) >> 1) + clicked, ((r.top + r.bottom + 1) >> 1) - 5 + clicked, str, TC_FROMSTRING);
+ DrawString(r.left + clicked, r.right + clicked, ((r.top + r.bottom + 1) >> 1) - 5 + clicked, str, TC_FROMSTRING, SA_CENTER);
break;
}