MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawScrollingStatusText

Function DrawScrollingStatusText

src/statusbar_gui.cpp:39–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37#include "safeguards.h"
38
39static bool DrawScrollingStatusText(const NewsItem &ni, int scroll_pos, int left, int right, int top, int bottom)
40{
41 /* Replace newlines and the likes with spaces. */
42 std::string message = StrMakeValid(ni.GetStatusText(), StringValidationSetting::ReplaceTabCrNlWithSpace);
43
44 DrawPixelInfo tmp_dpi;
45 if (!FillDrawPixelInfo(&tmp_dpi, left, top, right - left, bottom)) return true;
46
47 int width = GetStringBoundingBox(message).width;
48 int pos = (_current_text_dir == TD_RTL) ? (scroll_pos - width) : (right - scroll_pos - left);
49
50 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
51 DrawString(pos, INT16_MAX, 0, message, TC_LIGHT_BLUE, SA_LEFT | SA_FORCE);
52
53 return (_current_text_dir == TD_RTL) ? (pos < right - left) : (pos + width > 0);
54}
55
56struct StatusBarWindow : Window {
57 bool saving = false;

Callers 1

DrawWidgetMethod · 0.85

Calls 5

GetStringBoundingBoxFunction · 0.85
GetStatusTextMethod · 0.80
StrMakeValidFunction · 0.70
FillDrawPixelInfoFunction · 0.70
DrawStringFunction · 0.70

Tested by

no test coverage detected