diff options
-rw-r--r-- | src/console_gui.cpp | 13 | ||||
-rw-r--r-- | src/gfx.cpp | 26 | ||||
-rw-r--r-- | src/gfx_func.h | 1 | ||||
-rw-r--r-- | src/highscore_gui.cpp | 8 | ||||
-rw-r--r-- | src/misc_gui.cpp | 4 | ||||
-rw-r--r-- | src/network/network_chat_gui.cpp | 2 | ||||
-rw-r--r-- | src/network/network_gui.cpp | 8 | ||||
-rw-r--r-- | src/settings_gui.cpp | 19 | ||||
-rw-r--r-- | src/statusbar_gui.cpp | 2 | ||||
-rw-r--r-- | src/widget.cpp | 10 |
10 files changed, 35 insertions, 58 deletions
diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 9e87eb6f7..957d3684b 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -162,24 +162,25 @@ struct IConsoleWindow : Window virtual void OnPaint() { - int max = (this->height / ICON_LINE_HEIGHT) - 1; + const int max = (this->height / ICON_LINE_HEIGHT) - 1; + const int right = this->width - 1; + const IConsoleLine *print = IConsoleLine::Get(IConsoleWindow::scroll); GfxFillRect(this->left, this->top, this->width, this->height - 1, 0); for (int i = 0; i < max && print != NULL; i++, print = print->previous) { - DoDrawString(print->buffer, 5, - this->height - (2 + i) * ICON_LINE_HEIGHT, print->colour); + DrawString(5, right, this->height - (2 + i) * ICON_LINE_HEIGHT, print->buffer, print->colour); } /* If the text is longer than the window, don't show the starting ']' */ int delta = this->width - 10 - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH; if (delta > 0) { - DoDrawString("]", 5, this->height - ICON_LINE_HEIGHT, (TextColour)CC_COMMAND); + DrawString(5, right, this->height - ICON_LINE_HEIGHT, "]", (TextColour)CC_COMMAND); delta = 0; } - DoDrawString(_iconsole_cmdline.buf, 10 + delta, this->height - ICON_LINE_HEIGHT, (TextColour)CC_COMMAND); + DrawString(10 + delta, right, this->height - ICON_LINE_HEIGHT, _iconsole_cmdline.buf, (TextColour)CC_COMMAND); if (_focused_window == this && _iconsole_cmdline.caret) { - DoDrawString("_", 10 + delta + _iconsole_cmdline.caretxoffs, this->height - ICON_LINE_HEIGHT, TC_WHITE); + DrawString(10 + delta + _iconsole_cmdline.caretxoffs, right, this->height - ICON_LINE_HEIGHT, "_", TC_WHITE); } } diff --git a/src/gfx.cpp b/src/gfx.cpp index cff729e96..e4b5af4c0 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -766,32 +766,6 @@ void DrawCharCentered(WChar c, int x, int y, TextColour colour) /** Draw a string at the given coordinates with the given colour. * While drawing the string, parse it in case some formatting is specified, * like new colour, new size or even positionning. - * @param string The string to draw. This is not yet bidi reordered. - * @param x Offset from left side of the screen - * @param y Offset from top side of the screen - * @param colour Colour of the string, see _string_colourmap in - * table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h - * @param parse_string_also_when_clipped - * By default, always test the available space where to draw the string. - * When in multipline drawing, it would already be done, - * so no need to re-perform the same kind (more or less) of verifications. - * It's not only an optimisation, it's also a way to ensures the string will be parsed - * (as there are certain side effects on global variables, which are important for the next line) - * @return the x-coordinates where the drawing has finished. - * If nothing is drawn, the originally passed x-coordinate is returned - */ -int DoDrawString(const char *string, int x, int y, TextColour colour, bool parse_string_also_when_clipped) -{ - char buffer[DRAW_STRING_BUFFER]; - strecpy(buffer, string, lastof(buffer)); - HandleBiDiAndArabicShapes(buffer, lastof(buffer)); - - return ReallyDoDrawString(buffer, x, y, colour, parse_string_also_when_clipped); -} - -/** Draw a string at the given coordinates with the given colour. - * While drawing the string, parse it in case some formatting is specified, - * like new colour, new size or even positionning. * @param string The string to draw. This is already bidi reordered. * @param x Offset from left side of the screen * @param y Offset from top side of the screen diff --git a/src/gfx_func.h b/src/gfx_func.h index 2a8069029..2c051ebc7 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -96,7 +96,6 @@ int DrawString(int left, int right, int top, const char *str, TextColour colour, int DrawString(int left, int right, int top, StringID str, TextColour colour, StringAlignment align = SA_LEFT, bool underline = false); 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); void DrawCharCentered(uint32 c, int x, int y, TextColour colour); diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 095e973c0..1aca9dcf5 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -140,6 +140,8 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { this->SetupHighScoreEndWindow(&x, &y); + const int right = this->left + this->width - 1; + SetDParam(0, ORIGINAL_END_YEAR); SetDParam(1, this->window_number + STR_6801_EASY); DrawStringMultiCenter(x + (640 / 2), y + 62, !_networking ? STR_0211_TOP_COMPANIES_WHO_REACHED : STR_TOP_COMPANIES_NETWORK_GAME, 500); @@ -147,15 +149,15 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { /* Draw Highscore peepz */ for (uint8 i = 0; i < lengthof(_highscore_table[0]); i++) { SetDParam(0, i + 1); - DrawString(x + 40, y + 140 + (i * 55), STR_0212, TC_BLACK); + DrawString(x + 40, right, y + 140 + (i * 55), STR_0212, TC_BLACK); if (hs[i].company[0] != '\0') { TextColour colour = (this->rank == i) ? TC_RED : TC_BLACK; // draw new highscore in red - DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour); + DrawString(x + 71, right, y + 140 + (i * 55), hs[i].company, colour); SetDParam(0, hs[i].title); SetDParam(1, hs[i].score); - DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour); + DrawString(x + 71, right, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour); } } } diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index d74633750..009862c94 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1064,8 +1064,8 @@ void QueryString::DrawEditBox(Window *w, int wid) if (tb->caretxoffs + delta < 0) delta = -tb->caretxoffs; - DoDrawString(tb->buf, delta, 0, TC_YELLOW); - if (HasEditBoxFocus(w, wid) && tb->caret) DoDrawString("_", tb->caretxoffs + delta, 0, TC_WHITE); + DrawString(delta, tb->width, 0, tb->buf, TC_YELLOW); + if (HasEditBoxFocus(w, wid) && tb->caret) DrawString(tb->caretxoffs + delta, tb->width + 10, 0, "_", TC_WHITE); _cur_dpi = old_dpi; } diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 56ec30a3d..81ab4f30b 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -237,7 +237,7 @@ void NetworkDrawChatMessage() /* Paint the chat messages starting with the lowest at the bottom */ for (uint y = NETWORK_CHAT_LINE_HEIGHT; count-- != 0; y += NETWORK_CHAT_LINE_HEIGHT) { - DoDrawString(_chatmsg_list[count].message, _chatmsg_box.x + 3, _screen.height - _chatmsg_box.y - y + 1, _chatmsg_list[count].colour); + DrawString(_chatmsg_box.x + 3, _chatmsg_box.x + _chatmsg_box.width - 1, _screen.height - _chatmsg_box.y - y + 1, _chatmsg_list[count].message, _chatmsg_list[count].colour); } /* Make sure the data is updated next flush */ diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index ef4548472..3a05806f0 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -906,7 +906,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow { this->DrawEditBox(NSSW_GAMENAME); /* if password is set, draw red '*' next to 'Set password' button */ - if (!StrEmpty(_settings_client.network.server_password)) DoDrawString("*", 408, 23, TC_RED); + if (!StrEmpty(_settings_client.network.server_password)) DrawString(408, this->width - 2, 23, "*", TC_RED); /* draw list of maps */ GfxFillRect(11, 63, 258, 215, 0xD7); // black background of maps list @@ -919,7 +919,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow { if (pos == 0) { DrawString(14, y, STR_4010_GENERATE_RANDOM_NEW_GAME, TC_DARK_GREEN); } else { - DoDrawString(item->title, 14, y, _fios_colours[item->type] ); + DrawString(14, this->width - 1, y, item->title, _fios_colours[item->type] ); } y += NSSWND_ROWSIZE; @@ -1609,7 +1609,7 @@ struct NetworkClientListPopupWindow : Window { colour = TC_BLACK; } - DoDrawString(this->action[i], 4, y, colour); + DrawString(4, this->width - 4, y, this->action[i], colour); } } @@ -1718,7 +1718,7 @@ struct NetworkClientListWindow : Window /* Filter out spectators */ if (IsValidCompanyID(ci->client_playas)) DrawCompanyIcon(ci->client_playas, 64, y + 1); - DoDrawString(ci->client_name, 81, y, colour); + DrawString(81, this->width - 2, y, ci->client_name, colour); y += CLNWND_ROWSIZE; } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 91a4ab728..6d4f1e4fb 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1495,6 +1495,7 @@ struct CustomCurrencyWindow : Window { virtual void OnPaint() { + int const right = this->width - 1; int x; int y = 20; this->DrawWidgets(); @@ -1503,37 +1504,37 @@ struct CustomCurrencyWindow : Window { DrawArrowButtons(10, y, COLOUR_YELLOW, GB(this->click, 0, 2), true, true); SetDParam(0, 1); SetDParam(1, 1); - DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING); + DrawString(35, right, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING); y += 12; /* separator */ DrawFrameRect(10, y + 1, 29, y + 9, COLOUR_DARK_BLUE, GB(this->click, 2, 2) ? FR_LOWERED : FR_NONE); - x = DrawString(35, y + 1, STR_CURRENCY_SEPARATOR, TC_FROMSTRING); - DoDrawString(this->separator, x + 4, y + 1, TC_ORANGE); + x = DrawString(35, right, y + 1, STR_CURRENCY_SEPARATOR, TC_FROMSTRING); + DrawString(x + 4, right, y + 1, this->separator, TC_ORANGE); y += 12; /* prefix */ DrawFrameRect(10, y + 1, 29, y + 9, COLOUR_DARK_BLUE, GB(this->click, 4, 2) ? FR_LOWERED : FR_NONE); - x = DrawString(35, y + 1, STR_CURRENCY_PREFIX, TC_FROMSTRING); - DoDrawString(_custom_currency.prefix, x + 4, y + 1, TC_ORANGE); + x = DrawString(35, right, y + 1, STR_CURRENCY_PREFIX, TC_FROMSTRING); + DrawString(right, x + 4, y + 1, _custom_currency.prefix, TC_ORANGE); y += 12; /* suffix */ DrawFrameRect(10, y + 1, 29, y + 9, COLOUR_DARK_BLUE, GB(this->click, 6, 2) ? FR_LOWERED : FR_NONE); - x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING); - DoDrawString(_custom_currency.suffix, x + 4, y + 1, TC_ORANGE); + x = DrawString(35, right, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING); + DrawString(x + 4, right, y + 1, _custom_currency.suffix, TC_ORANGE); y += 12; /* switch to euro */ DrawArrowButtons(10, y, COLOUR_YELLOW, GB(this->click, 8, 2), true, true); SetDParam(0, _custom_currency.to_euro); - DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING); + DrawString(35, right, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING); y += 12; /* Preview */ y += 12; SetDParam(0, 10000); - DrawString(35, y + 1, STR_CURRENCY_PREVIEW, TC_FROMSTRING); + DrawString(35, right, y + 1, STR_CURRENCY_PREVIEW, TC_FROMSTRING); } virtual void OnClick(Point pt, int widget) diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 27d62f4cd..e8636f790 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -57,7 +57,7 @@ static bool DrawScrollingStatusText(const NewsItem *ni, int pos, int width) DrawPixelInfo *old_dpi = _cur_dpi; _cur_dpi = &tmp_dpi; - int x = DoDrawString(buffer, pos, 0, TC_LIGHT_BLUE); + int x = DrawString(pos, pos + width, 0, buffer, TC_LIGHT_BLUE); _cur_dpi = old_dpi; return x > 0; diff --git a/src/widget.cpp b/src/widget.cpp index 8fcca88ca..876723882 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -317,11 +317,11 @@ void Window::DrawWidgets() const /* draw up/down buttons */ clicked = ((this->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP); DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->colour, (clicked) ? FR_LOWERED : FR_NONE); - DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, TC_BLACK); + DrawString(r.left + 2 + clicked, r.right, r.top + clicked, UPARROW, TC_BLACK); clicked = (((this->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN)); DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE); - DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, TC_BLACK); + DrawString(r.left + 2 + clicked, r.right, r.bottom - 9 + clicked, DOWNARROW, TC_BLACK); int c1 = _colour_gradient[wi->colour & 0xF][3]; int c2 = _colour_gradient[wi->colour & 0xF][7]; @@ -348,11 +348,11 @@ void Window::DrawWidgets() const /* draw up/down buttons */ clicked = ((this->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2)); DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->colour, (clicked) ? FR_LOWERED : FR_NONE); - DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, TC_BLACK); + DrawString(r.left + 2 + clicked, r.right, r.top + clicked, UPARROW, TC_BLACK); clicked = ((this->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2)); DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->colour, (clicked) ? FR_LOWERED : FR_NONE); - DoDrawString(DOWNARROW, r.left + 2 + clicked, r.bottom - 9 + clicked, TC_BLACK); + DrawString(r.left + 2 + clicked, r.right, r.bottom - 9 + clicked, DOWNARROW, TC_BLACK); int c1 = _colour_gradient[wi->colour & 0xF][3]; int c2 = _colour_gradient[wi->colour & 0xF][7]; @@ -625,5 +625,5 @@ void Window::DrawSortButtonState(int widget, SortButtonState state) const if (state == SBS_OFF) return; int offset = this->IsWidgetLowered(widget) ? 1 : 0; - DoDrawString(state == SBS_DOWN ? DOWNARROW : UPARROW, this->widget[widget].right - 11 + offset, this->widget[widget].top + 1 + offset, TC_BLACK); + DrawString(this->widget[widget].right - 11 + offset, this->widget[widget].right, this->widget[widget].top + 1 + offset, state == SBS_DOWN ? DOWNARROW : UPARROW, TC_BLACK); } |