(svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.

pull/155/head
rubidium 15 years ago
parent 89d614deea
commit 2a422e3e95

@ -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) {

@ -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
}
}

@ -483,32 +483,6 @@ int DrawString(int left, int right, int top, StringID str, TextColour colour, St
return DrawString(left, right, top, buffer, lastof(buffer), colour, align, underline);
}
/**
* 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

@ -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);

@ -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;

@ -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);

@ -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);
}

@ -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;

@ -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));

@ -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);

@ -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 */

Loading…
Cancel
Save