|
@@ -24,21 +24,27 @@
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
#include "safeguards.h"
|
|
|
|
|
|
struct SubsidyListWindow : Window {
|
|
|
Scrollbar *vscroll;
|
|
|
Dimension cargo_icon_size;
|
|
|
|
|
|
SubsidyListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
|
|
{
|
|
|
this->CreateNestedTree();
|
|
|
this->vscroll = this->GetScrollbar(WID_SUL_SCROLLBAR);
|
|
|
this->FinishInitNested(window_number);
|
|
|
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;
|
|
|
|
|
|
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SUL_PANEL, WidgetDimensions::scaled.framerect.top);
|
|
|
int num = 0;
|
|
@@ -135,19 +141,29 @@ struct SubsidyListWindow : Window {
|
|
|
d.height *= 5;
|
|
|
d.width += WidgetDimensions::scaled.framerect.Horizontal();
|
|
|
d.height += WidgetDimensions::scaled.framerect.Vertical();
|
|
|
*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
|
|
|
{
|
|
|
if (widget != WID_SUL_PANEL) return;
|
|
|
|
|
|
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();
|
|
|
|
|
|
/* Section for drawing the offered subsidies */
|
|
|
if (IsInsideMM(pos, 0, cap)) DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_OFFERED_TITLE);
|
|
@@ -165,13 +181,14 @@ struct SubsidyListWindow : Window {
|
|
|
SetDParam(8, s->remaining + 1); // We get the rest of the current economy month for free, since the expiration is checked on each new month.
|
|
|
} else {
|
|
|
SetDParam(7, STR_SUBSIDIES_OFFERED_EXPIRY_DATE);
|
|
|
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++;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -199,13 +216,14 @@ struct SubsidyListWindow : Window {
|
|
|
else {
|
|
|
SetDParam(8, STR_SUBSIDIES_SUBSIDISED_EXPIRY_DATE);
|
|
|
SetDParam(9, TimerGameEconomy::date - ymd.day + s->remaining * 32);
|
|
|
}
|
|
|
|
|
|
/* Displays the two connected stations */
|
|
|
DrawString(tr.left, tr.right, tr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_FROM_TO);
|
|
|
DrawCargoIcon(tr, pos * GetCharacterHeight(FS_NORMAL), s->cargo_type);
|
|
|
DrawString(sr.left, sr.right, sr.top + pos * GetCharacterHeight(FS_NORMAL), STR_SUBSIDIES_SUBSIDISED_FROM_TO);
|
|
|
}
|
|
|
pos++;
|
|
|
num++;
|
|
|
}
|
|
|
}
|
|
|
|