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

Method DrawWidget

src/town_gui.cpp:233–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231 }
232
233 void DrawWidget(const Rect &r, WidgetID widget) const override
234 {
235 switch (widget) {
236 case WID_TA_ACTION_INFO:
237 if (this->sel_action != TownAction::End) {
238 Money action_cost = _price[PR_TOWN_ACTION] * GetTownActionCost(this->sel_action) >> 8;
239 bool affordable = Company::IsValidID(_local_company) && action_cost < GetAvailableMoney(_local_company);
240
241 DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.framerect),
242 GetString(this->action_tooltips[to_underlying(this->sel_action)], action_cost),
243 affordable ? TC_YELLOW : TC_RED);
244 }
245 break;
246 }
247 }
248
249 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
250 {

Callers

nothing calls this directly

Calls 6

GetTownActionCostFunction · 0.85
GetAvailableMoneyFunction · 0.85
to_underlyingFunction · 0.85
ShrinkMethod · 0.80
DrawStringMultiLineFunction · 0.70
GetStringFunction · 0.70

Tested by

no test coverage detected