@@ -27,6 +27,7 @@
struct SubsidyListWindow : Window {
Scrollbar *vscroll;
Dimension cargo_icon_size;
SubsidyListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{
@@ -36,6 +37,11 @@ struct SubsidyListWindow : Window {
this->OnInvalidateData(0);
}
void OnInit() override
this->cargo_icon_size = GetLargestCargoIconSize();
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
if (widget != WID_SUL_PANEL) return;
@@ -138,6 +144,15 @@ struct SubsidyListWindow : Window {
*size = maxdim(*size, d);
void DrawCargoIcon(const Rect &r, int y_offset, CargoID cid) const
bool rtl = _current_text_dir == TD_RTL;
SpriteID icon = CargoSpec::Get(cid)->GetCargoIcon();
Dimension d = GetSpriteSize(icon);
Rect ir = r.WithWidth(this->cargo_icon_size.width, rtl).WithHeight(GetCharacterHeight(FS_NORMAL));
DrawSprite(icon, PAL_NONE, CenterBounds(ir.left, ir.right, d.width), CenterBounds(ir.top, ir.bottom, this->cargo_icon_size.height) + y_offset);
void DrawWidget(const Rect &r, WidgetID widget) const override
@@ -145,6 +160,7 @@ struct SubsidyListWindow : Window {
TimerGameEconomy::YearMonthDay ymd = TimerGameEconomy::ConvertDateToYMD(TimerGameEconomy::date);
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
Rect sr = tr.Indent(this->cargo_icon_size.width + WidgetDimensions::scaled.hsep_normal, _current_text_dir == TD_RTL);
int pos = -this->vscroll->GetPosition();
const int cap = this->vscroll->GetCapacity();
@@ -168,7 +184,8 @@ struct SubsidyListWindow : Window {
SetDParam(8, TimerGameEconomy::date - ymd.day + s->remaining * 32);
DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_OFFERED_FROM_TO);
DrawCargoIcon(tr, pos * GetCharacterHeight(FS_NORMAL), s->cargo_type);
DrawString(sr.left, sr.right, sr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_OFFERED_FROM_TO);
pos++;
num++;
@@ -202,7 +219,8 @@ struct SubsidyListWindow : Window {
/* Displays the two connected stations */
DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_FROM_TO);
DrawString(sr.left, sr.right, sr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_FROM_TO);
Status change: