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

Method DrawWidget

src/signs_gui.cpp:191–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189 }
190
191 void DrawWidget(const Rect &r, WidgetID widget) const override
192 {
193 switch (widget) {
194 case WID_SIL_LIST: {
195 Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
196 uint text_offset_y = (this->resize.step_height - GetCharacterHeight(FS_NORMAL) + 1) / 2;
197 /* No signs? */
198 if (this->vscroll->GetCount() == 0) {
199 DrawString(tr.left, tr.right, tr.top + text_offset_y, STR_STATION_LIST_NONE);
200 return;
201 }
202
203 Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
204 bool rtl = _current_text_dir == TD_RTL;
205 int sprite_offset_y = (this->resize.step_height - d.height + 1) / 2;
206 uint icon_left = rtl ? tr.right - this->text_offset : tr.left;
207 tr = tr.Indent(this->text_offset, rtl);
208
209 /* At least one sign available. */
210 auto [first, last] = this->vscroll->GetVisibleRangeIterators(this->signs);
211 for (auto it = first; it != last; ++it) {
212 const Sign *si = *it;
213
214 if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, tr.top + sprite_offset_y);
215
216 DrawString(tr.left, tr.right, tr.top + text_offset_y, GetString(STR_SIGN_NAME, si->index), TC_YELLOW);
217 tr.top += this->resize.step_height;
218 }
219 break;
220 }
221 }
222 }
223
224 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
225 {

Callers

nothing calls this directly

Calls 9

GetCharacterHeightFunction · 0.85
GetSpriteSizeFunction · 0.85
DrawCompanyIconFunction · 0.85
ShrinkMethod · 0.80
IndentMethod · 0.80
DrawStringFunction · 0.70
GetStringFunction · 0.70
GetCountMethod · 0.45

Tested by

no test coverage detected