diff options
author | rubidium <rubidium@openttd.org> | 2009-03-21 22:22:00 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-03-21 22:22:00 +0000 |
commit | 69decac4065847ee5384ed68cc70c2d68bc3ddb4 (patch) | |
tree | 490f52839e2087bf44ad9edab6d75d9557f3525f | |
parent | 900364109597f02413e2f7a59e9b4e6cc9fdf97f (diff) | |
download | openttd-69decac4065847ee5384ed68cc70c2d68bc3ddb4.tar.xz |
(svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
-rw-r--r-- | src/company_gui.cpp | 18 | ||||
-rw-r--r-- | src/depot_gui.cpp | 4 | ||||
-rw-r--r-- | src/gfx.cpp | 26 | ||||
-rw-r--r-- | src/gfx_func.h | 3 | ||||
-rw-r--r-- | src/graph_gui.cpp | 4 | ||||
-rw-r--r-- | src/group_gui.cpp | 2 | ||||
-rw-r--r-- | src/network/network_chat_gui.cpp | 2 | ||||
-rw-r--r-- | src/network/network_content_gui.cpp | 2 | ||||
-rw-r--r-- | src/news_gui.cpp | 2 | ||||
-rw-r--r-- | src/station_gui.cpp | 6 | ||||
-rw-r--r-- | src/statusbar_gui.cpp | 4 |
11 files changed, 22 insertions, 51 deletions
diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 3703e2b1f..7e8ce5ffc 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -99,7 +99,7 @@ static void DrawCompanyEconomyStats(const Company *c, bool small) ExpensesType et = _expenses_list_types[type].et[i]; if (et == INVALID_EXPENSES) { y += 2; - DrawStringRightAligned(111, y, STR_7020_TOTAL, TC_FROMSTRING); + DrawString(0, 111, y, STR_7020_TOTAL, TC_FROMSTRING, SA_RIGHT); y += 20; } else { DrawString(2, y, STR_7011_CONSTRUCTION + et, TC_FROMSTRING); @@ -107,7 +107,7 @@ static void DrawCompanyEconomyStats(const Company *c, bool small) } } - DrawStringRightAligned(111, y + 2, STR_7020_TOTAL, TC_FROMSTRING); + DrawString(0, 111, y + 2, STR_7020_TOTAL, TC_FROMSTRING, SA_RIGHT); /* draw the price columns */ year = _cur_year - 2; @@ -118,7 +118,7 @@ static void DrawCompanyEconomyStats(const Company *c, bool small) do { if (year >= c->inaugurated_year) { SetDParam(0, year); - DrawStringRightAlignedUnderline(x, 15, STR_7010, TC_FROMSTRING); + DrawString(x - 75, x, 15, STR_7010, TC_FROMSTRING, SA_RIGHT, true); Money sum = 0; Money subtotal = 0; @@ -144,7 +144,7 @@ static void DrawCompanyEconomyStats(const Company *c, bool small) str = STR_701E; if (cost < 0) { cost = -cost; str++; } SetDParam(0, cost); - DrawStringRightAligned(x, y, str, TC_FROMSTRING); + DrawString(x - 75, x, y, str, TC_FROMSTRING, SA_RIGHT); } y += (et == INVALID_EXPENSES) ? 20 : 10; } @@ -152,7 +152,7 @@ static void DrawCompanyEconomyStats(const Company *c, bool small) str = STR_701E; if (sum < 0) { sum = -sum; str++; } SetDParam(0, sum); - DrawStringRightAligned(x, y + 2, str, TC_FROMSTRING); + DrawString(x - 75, x, y + 2, str, TC_FROMSTRING, SA_RIGHT); GfxFillRect(x - 75, y, x, y, 215); x += 95; @@ -172,20 +172,20 @@ static void DrawCompanyEconomyStats(const Company *c, bool small) DrawString(2, y, STR_7026_BANK_BALANCE, TC_FROMSTRING); SetDParam(0, c->money); - DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING); + DrawString(182 - 75, 182, y, STR_7028, TC_FROMSTRING, SA_RIGHT); y += 10; DrawString(2, y, STR_7027_LOAN, TC_FROMSTRING); SetDParam(0, c->current_loan); - DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING); + DrawString(182 - 75, 182, y, STR_7028, TC_FROMSTRING, SA_RIGHT); y += 12; GfxFillRect(182 - 75, y - 2, 182, y - 2, 215); SetDParam(0, c->money - c->current_loan); - DrawStringRightAligned(182, y, STR_7028, TC_FROMSTRING); + DrawString(182 - 75, 182, y, STR_7028, TC_FROMSTRING, SA_RIGHT); } enum CompanyFinancesWindowWidgets { @@ -819,7 +819,7 @@ class SelectCompanyManagerFaceWindow : public Window void DrawFaceStringLabel(byte widget_index, StringID str, uint8 val, bool is_bool_widget) { /* Write the label in gold (0x2) to the left of the button. */ - DrawStringRightAligned(this->widget[widget_index].left - (is_bool_widget ? 5 : 14), this->widget[widget_index].top + 1, str, TC_GOLD); + DrawString(0, this->widget[widget_index].left - (is_bool_widget ? 5 : 14), this->widget[widget_index].top + 1, str, TC_GOLD, SA_RIGHT); if (!this->IsWidgetDisabled(widget_index)) { if (is_bool_widget) { diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index fafa0a935..e6988d08a 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -272,7 +272,7 @@ struct DepotWindow : Window { /* Number of wagons relative to a standard length wagon (rounded up) */ SetDParam(0, (v->u.rail.cached_total_length + 7) / 8); - DrawStringRightAligned(this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter + DrawString(this->widget[DEPOT_WIDGET_MATRIX].left, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING, SA_RIGHT); // Draw the counter break; case VEH_ROAD: DrawRoadVehImage( v, x + 24, sprite_y, this->sel, 1); break; @@ -376,7 +376,7 @@ struct DepotWindow : Window { u = v; do i++; while ((u = u->Next()) != NULL); // Determine length of train SetDParam(0, i); // Set the counter - DrawStringRightAligned(this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter + DrawString(this->widget[DEPOT_WIDGET_MATRIX].left, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING, SA_RIGHT); // Draw the counter } } diff --git a/src/gfx.cpp b/src/gfx.cpp index aef176151..cff729e96 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -484,32 +484,6 @@ int DrawString(int left, int right, int top, StringID str, TextColour colour, St } /** - * Draw string right-aligned. - * - * @param x Right-most x position of the string - * @param y Y position of the string - * @param str String to draw - * @param colour Colour used for drawing the string, see DoDrawString() for details - */ -int DrawStringRightAligned(int x, int y, StringID str, TextColour colour) -{ - return DrawString(0, x, y, str, colour, SA_RIGHT, false); -} - -/** - * Draw string right-aligned with a line underneath it. - * - * @param x Right-most x position of the string - * @param y Y position of the string - * @param str String to draw - * @param colour Colour used for drawing the string, see DoDrawString() for details - */ -int DrawStringRightAlignedUnderline(int x, int y, StringID str, TextColour colour) -{ - return DrawString(0, x, y, str, colour, SA_RIGHT, 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 43ac66491..2a8069029 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -98,9 +98,6 @@ int DrawString(int left, int right, int top, StringID str, TextColour colour, St 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 DrawStringRightAligned(int x, int y, StringID str, TextColour colour); -int DrawStringRightAlignedUnderline(int x, int y, StringID str, TextColour colour); - void DrawCharCentered(uint32 c, int x, int y, TextColour colour); void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE); diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 3429fb409..1d32f1f5c 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -248,7 +248,7 @@ protected: for (int i = 0; i < GRAPH_NUM_LINES_Y; i++) { SetDParam(0, this->format_str_y_axis); SetDParam(1, y_label); - DrawStringRightAligned(x, y, STR_0170, graph_axis_label_colour); + DrawString(x - GRAPH_X_POSITION_BEGINNING, x, y, STR_0170, graph_axis_label_colour, SA_RIGHT); y_label -= y_label_separation; y += (this->gd_height / (GRAPH_NUM_LINES_Y - 1)); @@ -982,7 +982,7 @@ public: /* Draw the score */ SetDParam(0, score); - DrawStringRightAligned(107, y, STR_PERFORMANCE_DETAIL_INT, TC_FROMSTRING); + DrawString(0, 107, y, STR_PERFORMANCE_DETAIL_INT, TC_FROMSTRING, SA_RIGHT); /* Calculate the %-bar */ x = Clamp(val, 0, needed) * 50 / needed; diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 0a636c9f2..8cc8821bc 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -430,7 +430,7 @@ public: /* draw the number of vehicles of the group */ SetDParam(0, g->num_vehicle); - DrawStringRightAligned(187, y1 + 1, STR_GROUP_TINY_NUM, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK); + DrawString(this->widget[GRP_WIDGET_LIST_GROUP].left, this->widget[GRP_WIDGET_LIST_GROUP].right, y1 + 1, STR_GROUP_TINY_NUM, (this->group_sel == g->index) ? TC_WHITE : TC_BLACK, SA_RIGHT); } this->DrawSortButtonState(GRP_WIDGET_SORT_BY_ORDER, this->vehicles.IsDescSortOrder() ? SBS_DOWN : SBS_UP); diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index fc77b56c6..56ec30a3d 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -445,7 +445,7 @@ public: this->DrawWidgets(); assert((uint)this->dtype < lengthof(chat_captions)); - DrawStringRightAligned(this->widget[NWCW_TEXTBOX].left - 2, this->widget[NWCW_TEXTBOX].top + 1, chat_captions[this->dtype], TC_BLACK); + DrawString(this->widget[NWCW_BACKGROUND].left, this->widget[NWCW_TEXTBOX].left - 2, this->widget[NWCW_TEXTBOX].top + 1, chat_captions[this->dtype], TC_BLACK, SA_RIGHT); this->DrawEditBox(NWCW_TEXTBOX); } diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index f70502f9c..d746fe93c 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -392,7 +392,7 @@ public: /* Edit box to filter for keywords */ this->DrawEditBox(NCLWW_FILTER); - DrawStringRightAligned(this->widget[NCLWW_FILTER].left - 8, this->widget[NCLWW_FILTER].top + 2, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING); + DrawString(this->widget[NCLWW_MATRIX].left, this->widget[NCLWW_FILTER].left - 8, this->widget[NCLWW_FILTER].top + 2, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING, SA_RIGHT); switch (this->content.SortType()) { case NCLWW_CHECKBOX - NCLWW_CHECKBOX: this->DrawSortButtonState(NCLWW_CHECKBOX, arrow); break; diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 1755f03dc..52fe64e5b 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -216,7 +216,7 @@ struct NewsWindow : Window { DrawString(2, 1, STR_00C6, TC_FROMSTRING); SetDParam(0, this->ni->date); - DrawStringRightAligned(428, 1, STR_01FF, TC_FROMSTRING); + DrawString(1, this->width - 1, 1, STR_01FF, TC_FROMSTRING, SA_RIGHT); if (!(this->ni->flags & NF_VIEWPORT)) { CopyInDParam(0, this->ni->params, lengthof(this->ni->params)); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index ea35138cd..460f4a947 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -817,10 +817,10 @@ struct StationViewWindow : public Window { if (HasBit(transfers, cd->cargo)) { /* This cargo has transfers waiting so show the expand or shrink 'button' */ const char *sym = HasBit(this->cargo, cd->cargo) ? "-" : "+"; - DrawStringRightAligned(x + width - 8, y, STR_0009, TC_FROMSTRING); - DoDrawString(sym, x + width - 6, y, TC_YELLOW); + DrawString(this->widget[SVW_WAITING].left, this->widget[SVW_WAITING].right - 12, y, STR_0009, TC_FROMSTRING, SA_RIGHT); + DrawString(this->widget[SVW_WAITING].right - 10, this->widget[SVW_WAITING].right, y, sym, TC_YELLOW); } else { - DrawStringRightAligned(x + width, y, STR_0009, TC_FROMSTRING); + DrawString(this->widget[SVW_WAITING].left, this->widget[SVW_WAITING].right - 4, y, STR_0009, TC_FROMSTRING, SA_RIGHT); } } else { SetDParam(0, cd->cargo); diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 4849c7050..27d62f4cd 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -97,12 +97,12 @@ struct StatusBarWindow : Window { this->DrawWidgets(); SetDParam(0, _date); - 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); + DrawString(this->widget[SBW_RIGHT].left + 1, this->widget[SBW_RIGHT].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); - DrawString(this->widget[SBW_MIDDLE].left + 1, this->widget[SBW_MIDDLE].right - 1, 1, STR_0004, TC_FROMSTRING, SA_CENTER); + DrawString(this->widget[SBW_LEFT].left + 1, this->widget[SBW_LEFT].right - 1, 1, STR_0004, TC_FROMSTRING, SA_CENTER); } /* Draw status bar */ |