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

Method DrawWidget

src/ai/ai_gui.cpp:190–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188 }
189
190 void DrawWidget(const Rect &r, WidgetID widget) const override
191 {
192 switch (widget) {
193 case WID_AIC_LIST: {
194 Rect tr = r.Shrink(WidgetDimensions::scaled.matrix);
195 int max_slot = GetGameSettings().difficulty.max_no_competitors;
196 if (_game_mode == GM_NORMAL) {
197 for (const Company *c : Company::Iterate()) {
198 if (c->is_ai) max_slot--;
199 }
200 for (CompanyID cid = CompanyID::Begin(); cid < max_slot && cid < MAX_COMPANIES; ++cid) {
201 if (Company::IsValidID(cid)) max_slot++;
202 }
203 } else {
204 max_slot++; // Slot 0 is human
205 }
206 for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < MAX_COMPANIES; i++) {
207 CompanyID cid = static_cast<CompanyID>(i);
208 DrawString(tr, this->GetSlotText(cid), this->GetSlotColour(cid, static_cast<CompanyID>(max_slot)));
209 tr.top += this->line_height;
210 }
211 break;
212 }
213 }
214 }
215
216 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
217 {

Callers

nothing calls this directly

Calls 7

GetSlotTextMethod · 0.95
GetSlotColourMethod · 0.95
BeginFunction · 0.85
ShrinkMethod · 0.80
GetPositionMethod · 0.80
DrawStringFunction · 0.50
IsVisibleMethod · 0.45

Tested by

no test coverage detected