Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -28,8 +28,8 @@
|
||||
#include "safeguards.h"
|
||||
|
||||
struct SubsidyListWindow : Window {
|
||||
Scrollbar *vscroll;
|
||||
Dimension cargo_icon_size;
|
||||
Scrollbar *vscroll = nullptr;
|
||||
Dimension cargo_icon_size{};
|
||||
|
||||
SubsidyListWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc)
|
||||
{
|
||||
@@ -84,9 +84,9 @@ struct SubsidyListWindow : Window {
|
||||
{
|
||||
/* determine src coordinate for subsidy and try to scroll to it */
|
||||
TileIndex xy;
|
||||
switch (s->src_type) {
|
||||
case SourceType::Industry: xy = Industry::Get(s->src)->location.tile; break;
|
||||
case SourceType::Town: xy = Town::Get(s->src)->xy; break;
|
||||
switch (s->src.type) {
|
||||
case SourceType::Industry: xy = Industry::Get(s->src.ToIndustryID())->location.tile; break;
|
||||
case SourceType::Town: xy = Town::Get(s->src.ToTownID())->xy; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
@@ -94,9 +94,9 @@ struct SubsidyListWindow : Window {
|
||||
if (citymania::_fn_mod) ShowExtraViewportWindow(xy);
|
||||
|
||||
/* otherwise determine dst coordinate for subsidy and scroll to it */
|
||||
switch (s->dst_type) {
|
||||
case SourceType::Industry: xy = Industry::Get(s->dst)->location.tile; break;
|
||||
case SourceType::Town: xy = Town::Get(s->dst)->xy; break;
|
||||
switch (s->dst.type) {
|
||||
case SourceType::Industry: xy = Industry::Get(s->dst.ToIndustryID())->location.tile; break;
|
||||
case SourceType::Town: xy = Town::Get(s->dst.ToTownID())->xy; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
@@ -146,10 +146,10 @@ struct SubsidyListWindow : Window {
|
||||
size = maxdim(size, d);
|
||||
}
|
||||
|
||||
void DrawCargoIcon(const Rect &r, int y_offset, CargoID cid) const
|
||||
void DrawCargoIcon(const Rect &r, int y_offset, CargoType cargo_type) const
|
||||
{
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
SpriteID icon = CargoSpec::Get(cid)->GetCargoIcon();
|
||||
SpriteID icon = CargoSpec::Get(cargo_type)->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);
|
||||
@@ -176,18 +176,24 @@ struct SubsidyListWindow : Window {
|
||||
if (!s->IsAwarded()) {
|
||||
if (IsInsideMM(pos, 0, cap)) {
|
||||
/* Displays the two offered towns */
|
||||
SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::Gui);
|
||||
const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
|
||||
std::string text;
|
||||
|
||||
/* If using wallclock units, show minutes remaining. Otherwise show the date when the subsidy ends. */
|
||||
if (TimerGameEconomy::UsingWallclockUnits()) {
|
||||
SetDParam(7, STR_SUBSIDIES_OFFERED_EXPIRY_TIME);
|
||||
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.
|
||||
text = GetString(STR_SUBSIDIES_OFFERED_FROM_TO,
|
||||
cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id,
|
||||
STR_SUBSIDIES_OFFERED_EXPIRY_TIME,
|
||||
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);
|
||||
text = GetString(STR_SUBSIDIES_OFFERED_FROM_TO,
|
||||
cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id,
|
||||
STR_SUBSIDIES_OFFERED_EXPIRY_DATE,
|
||||
TimerGameEconomy::date.base() - ymd.day + s->remaining * 32);
|
||||
}
|
||||
|
||||
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);
|
||||
DrawString(sr.left, sr.right, sr.top + pos * GetCharacterHeight(FS_NORMAL), text);
|
||||
}
|
||||
pos++;
|
||||
num++;
|
||||
@@ -208,21 +214,27 @@ struct SubsidyListWindow : Window {
|
||||
for (const Subsidy *s : Subsidy::Iterate()) {
|
||||
if (s->IsAwarded()) {
|
||||
if (IsInsideMM(pos, 0, cap)) {
|
||||
SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::Gui);
|
||||
SetDParam(7, s->awarded);
|
||||
const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
|
||||
std::string text;
|
||||
|
||||
/* If using wallclock units, show minutes remaining. Otherwise show the date when the subsidy ends. */
|
||||
if (TimerGameEconomy::UsingWallclockUnits()) {
|
||||
SetDParam(8, STR_SUBSIDIES_SUBSIDISED_EXPIRY_TIME);
|
||||
SetDParam(9, s->remaining);
|
||||
}
|
||||
else {
|
||||
SetDParam(8, STR_SUBSIDIES_SUBSIDISED_EXPIRY_DATE);
|
||||
SetDParam(9, TimerGameEconomy::date - ymd.day + s->remaining * 32);
|
||||
text = GetString(STR_SUBSIDIES_SUBSIDISED_FROM_TO,
|
||||
cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id,
|
||||
GetString(STR_COMPANY_NAME, s->awarded),
|
||||
STR_SUBSIDIES_SUBSIDISED_EXPIRY_TIME,
|
||||
s->remaining + 1); // We get the rest of the current economy month for free, since the expiration is checked on each new month.
|
||||
} else {
|
||||
text = GetString(STR_SUBSIDIES_SUBSIDISED_FROM_TO,
|
||||
cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id,
|
||||
GetString(STR_COMPANY_NAME, s->awarded),
|
||||
STR_SUBSIDIES_SUBSIDISED_EXPIRY_DATE,
|
||||
TimerGameEconomy::date.base() - ymd.day + s->remaining * 32);
|
||||
}
|
||||
|
||||
/* Displays the two connected stations */
|
||||
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);
|
||||
DrawString(sr.left, sr.right, sr.top + pos * GetCharacterHeight(FS_NORMAL), text);
|
||||
}
|
||||
pos++;
|
||||
num++;
|
||||
@@ -255,13 +267,13 @@ struct SubsidyListWindow : Window {
|
||||
static constexpr NWidgetPart _nested_subsidies_list_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_SUBSIDIES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_SUBSIDIES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_SUL_PANEL), SetDataTip(0x0, STR_SUBSIDIES_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER), SetResize(1, 1), SetScrollbar(WID_SUL_SCROLLBAR), EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_SUL_PANEL), SetToolTip(STR_SUBSIDIES_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER), SetResize(1, 1), SetScrollbar(WID_SUL_SCROLLBAR), EndContainer(),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_SUL_SCROLLBAR),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
|
||||
@@ -272,7 +284,7 @@ static constexpr NWidgetPart _nested_subsidies_list_widgets[] = {
|
||||
static WindowDesc _subsidies_list_desc(
|
||||
WDP_AUTO, "list_subsidies", 500, 127,
|
||||
WC_SUBSIDIES_LIST, WC_NONE,
|
||||
0,
|
||||
{},
|
||||
_nested_subsidies_list_widgets
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user