Merge remote-tracking branch 'upstream/master' into 13.0
This commit is contained in:
+56
-54
@@ -198,7 +198,7 @@ static void StationsWndShowStationRating(int left, int right, int y, CargoID typ
|
||||
const CargoSpec *cs = CargoSpec::Get(type);
|
||||
if (!cs->IsValid()) return;
|
||||
|
||||
int padding = ScaleFontTrad(1);
|
||||
int padding = ScaleGUITrad(1);
|
||||
int width = right - left;
|
||||
int colour = cs->rating_colour;
|
||||
TextColour tc = GetContrastColour(colour);
|
||||
@@ -212,7 +212,7 @@ static void StationsWndShowStationRating(int left, int right, int y, CargoID typ
|
||||
} else {
|
||||
/* Draw a (scaled) one pixel-wide bar of additional cargo meter, useful
|
||||
* for stations with only a small amount (<=30) */
|
||||
uint rest = ScaleFontTrad(amount) / 5;
|
||||
uint rest = ScaleGUITrad(amount) / 5;
|
||||
if (rest != 0) {
|
||||
GfxFillRect(left, y + height - rest, left + padding - 1, y + height, colour);
|
||||
}
|
||||
@@ -426,8 +426,8 @@ public:
|
||||
}
|
||||
|
||||
case WID_STL_LIST:
|
||||
resize->height = std::max(FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL + ScaleFontTrad(3));
|
||||
size->height = WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM;
|
||||
resize->height = std::max(FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL + ScaleGUITrad(3));
|
||||
size->height = padding.height + 5 * resize->height;
|
||||
|
||||
/* Determine appropriate width for mini station rating graph */
|
||||
this->rating_width = 0;
|
||||
@@ -468,12 +468,12 @@ public:
|
||||
case WID_STL_LIST: {
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
int max = std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
|
||||
int y = r.top + WD_FRAMERECT_TOP;
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||
uint line_height = this->GetWidget<NWidgetBase>(widget)->resize_y;
|
||||
/* Spacing between station name and first rating graph. */
|
||||
int text_spacing = ScaleFontTrad(5);
|
||||
int text_spacing = WidgetDimensions::scaled.hsep_wide;
|
||||
/* Spacing between additional rating graphs. */
|
||||
int rating_spacing = ScaleFontTrad(4);
|
||||
int rating_spacing = WidgetDimensions::scaled.hsep_normal;
|
||||
|
||||
for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner
|
||||
const Station *st = this->stations[i];
|
||||
@@ -485,7 +485,7 @@ public:
|
||||
|
||||
SetDParam(0, st->index);
|
||||
SetDParam(1, st->facilities);
|
||||
int x = DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_STATION);
|
||||
int x = DrawString(tr.left, tr.right, tr.top + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_STATION);
|
||||
x += rtl ? -text_spacing : text_spacing;
|
||||
|
||||
/* show cargo waiting and station ratings */
|
||||
@@ -498,20 +498,20 @@ public:
|
||||
* the space. */
|
||||
if (rtl) {
|
||||
x -= rating_width + rating_spacing;
|
||||
if (x < r.left + WD_FRAMERECT_LEFT) break;
|
||||
if (x < tr.left) break;
|
||||
}
|
||||
StationsWndShowStationRating(x, x + rating_width, y, cid, st->goods[cid].cargo.TotalCount(), st->goods[cid].rating);
|
||||
StationsWndShowStationRating(x, x + rating_width, tr.top, cid, st->goods[cid].cargo.TotalCount(), st->goods[cid].rating);
|
||||
if (!rtl) {
|
||||
x += rating_width + rating_spacing;
|
||||
if (x > r.right - WD_FRAMERECT_RIGHT) break;
|
||||
if (x > tr.right) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
y += line_height;
|
||||
tr.top += line_height;
|
||||
}
|
||||
|
||||
if (this->vscroll->GetCount() == 0) { // company has no stations
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_LIST_NONE);
|
||||
DrawString(tr.left, tr.right, tr.top + (line_height - FONT_HEIGHT_NORMAL) / 2, STR_STATION_LIST_NONE);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -519,11 +519,13 @@ public:
|
||||
|
||||
default:
|
||||
if (widget >= WID_STL_CARGOSTART) {
|
||||
Rect br = r.Shrink(WidgetDimensions::scaled.bevel);
|
||||
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_STL_CARGOSTART];
|
||||
int cg_ofst = HasBit(this->cargo_filter, cs->Index()) ? 1 : 0;
|
||||
GfxFillRect(r.left + cg_ofst + 1, r.top + cg_ofst + 1, r.right - 1 + cg_ofst, r.bottom - 1 + cg_ofst, cs->rating_colour);
|
||||
int cg_ofst = HasBit(this->cargo_filter, cs->Index()) ? WidgetDimensions::scaled.pressed : 0;
|
||||
br = br.Translate(cg_ofst, cg_ofst);
|
||||
GfxFillRect(br, cs->rating_colour);
|
||||
TextColour tc = GetContrastColour(cs->rating_colour);
|
||||
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + (r.bottom - r.top - FONT_HEIGHT_SMALL) / 2 + cg_ofst, cs->abbrev, tc, SA_HOR_CENTER);
|
||||
DrawString(br.left, br.right, CenterBounds(br.top, br.bottom, FONT_HEIGHT_SMALL), cs->abbrev, tc, SA_HOR_CENTER);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -674,7 +676,7 @@ public:
|
||||
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_STL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_STL_LIST, WidgetDimensions::scaled.framerect.Vertical());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,7 +846,7 @@ static const NWidgetPart _nested_station_view_widgets[] = {
|
||||
*/
|
||||
static void DrawCargoIcons(CargoID i, uint waiting, int left, int right, int y)
|
||||
{
|
||||
int width = ScaleGUITrad(10);
|
||||
int width = ScaleSpriteTrad(10);
|
||||
uint num = std::min<uint>((waiting + (width / 2)) / width, (right - left) / width); // maximum is width / 10 icons so it won't overflow
|
||||
if (num == 0) return;
|
||||
|
||||
@@ -1402,12 +1404,12 @@ struct StationViewWindow : public Window {
|
||||
switch (widget) {
|
||||
case WID_SV_WAITING:
|
||||
resize->height = FONT_HEIGHT_NORMAL;
|
||||
size->height = WD_FRAMERECT_TOP + 4 * resize->height + WD_FRAMERECT_BOTTOM;
|
||||
this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
size->height = 4 * resize->height + padding.height;
|
||||
this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width);
|
||||
break;
|
||||
|
||||
case WID_SV_ACCEPT_RATING_LIST:
|
||||
size->height = WD_FRAMERECT_TOP + ((this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
|
||||
size->height = ((this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * FONT_HEIGHT_NORMAL + padding.height;
|
||||
break;
|
||||
|
||||
case WID_SV_CLOSE_AIRPORT:
|
||||
@@ -1475,7 +1477,7 @@ struct StationViewWindow : public Window {
|
||||
|
||||
/* Draw waiting cargo. */
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_SV_WAITING);
|
||||
Rect waiting_rect = nwi->GetCurrentRect();
|
||||
Rect waiting_rect = nwi->GetCurrentRect().Shrink(WidgetDimensions::scaled.framerect);
|
||||
this->DrawEntries(&cargo, waiting_rect, pos, maxrows, 0);
|
||||
scroll_to_row = INT_MAX;
|
||||
}
|
||||
@@ -1747,7 +1749,7 @@ struct StationViewWindow : public Window {
|
||||
* @param cargo Current cargo being drawn (if cargo column has been passed).
|
||||
* @return row (in "pos" counting) after the one we have last drawn to.
|
||||
*/
|
||||
int DrawEntries(CargoDataEntry *entry, Rect &r, int pos, int maxrows, int column, CargoID cargo = CT_INVALID)
|
||||
int DrawEntries(CargoDataEntry *entry, const Rect &r, int pos, int maxrows, int column, CargoID cargo = CT_INVALID)
|
||||
{
|
||||
if (this->sortings[column] == ST_AS_GROUPING) {
|
||||
if (this->groupings[column] != GR_CARGO) {
|
||||
@@ -1765,13 +1767,13 @@ struct StationViewWindow : public Window {
|
||||
|
||||
if (pos > -maxrows && pos <= 0) {
|
||||
StringID str = STR_EMPTY;
|
||||
int y = r.top + WD_FRAMERECT_TOP - pos * FONT_HEIGHT_NORMAL;
|
||||
int y = r.top - pos * FONT_HEIGHT_NORMAL;
|
||||
SetDParam(0, cargo);
|
||||
SetDParam(1, cd->GetCount());
|
||||
|
||||
if (this->groupings[column] == GR_CARGO) {
|
||||
str = STR_STATION_VIEW_WAITING_CARGO;
|
||||
DrawCargoIcons(cd->GetCargo(), cd->GetCount(), r.left + WD_FRAMERECT_LEFT + this->expand_shrink_width, r.right - WD_FRAMERECT_RIGHT - this->expand_shrink_width, y);
|
||||
DrawCargoIcons(cd->GetCargo(), cd->GetCount(), r.left + this->expand_shrink_width, r.right - this->expand_shrink_width, y);
|
||||
} else {
|
||||
if (!auto_distributed) grouping = GR_SOURCE;
|
||||
StationID station = cd->GetStation();
|
||||
@@ -1796,12 +1798,10 @@ struct StationViewWindow : public Window {
|
||||
}
|
||||
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
int text_left = rtl ? r.left + this->expand_shrink_width : r.left + WD_FRAMERECT_LEFT + column * this->expand_shrink_width;
|
||||
int text_right = rtl ? r.right - WD_FRAMERECT_LEFT - column * this->expand_shrink_width : r.right - this->expand_shrink_width;
|
||||
int shrink_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - this->expand_shrink_width + WD_FRAMERECT_LEFT;
|
||||
int shrink_right = rtl ? r.left + this->expand_shrink_width - WD_FRAMERECT_RIGHT : r.right - WD_FRAMERECT_RIGHT;
|
||||
Rect text = r.Indent(column * WidgetDimensions::scaled.hsep_indent, rtl).Indent(this->expand_shrink_width, !rtl);
|
||||
Rect shrink = r.WithWidth(this->expand_shrink_width, !rtl);
|
||||
|
||||
DrawString(text_left, text_right, y, str);
|
||||
DrawString(text.left, text.right, y, str);
|
||||
|
||||
if (column < NUM_COLUMNS - 1) {
|
||||
const char *sym = nullptr;
|
||||
@@ -1816,7 +1816,7 @@ struct StationViewWindow : public Window {
|
||||
sym = "+";
|
||||
}
|
||||
}
|
||||
if (sym) DrawString(shrink_left, shrink_right, y, sym, TC_YELLOW);
|
||||
if (sym != nullptr) DrawString(shrink.left, shrink.right, y, sym, TC_YELLOW);
|
||||
}
|
||||
this->SetDisplayedRow(cd);
|
||||
}
|
||||
@@ -1836,14 +1836,15 @@ struct StationViewWindow : public Window {
|
||||
int DrawAcceptedCargo(const Rect &r) const
|
||||
{
|
||||
const Station *st = Station::Get(this->window_number);
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
||||
CargoTypes cargo_mask = 0;
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
if (HasBit(st->goods[i].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(cargo_mask, i);
|
||||
}
|
||||
SetDParam(0, cargo_mask);
|
||||
int bottom = DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO);
|
||||
return CeilDiv(bottom - r.top - WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL);
|
||||
int bottom = DrawStringMultiLine(tr.left, tr.right, tr.top, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO);
|
||||
return CeilDiv(bottom - r.top - WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1854,18 +1855,19 @@ struct StationViewWindow : public Window {
|
||||
int DrawCargoRatings(const Rect &r)
|
||||
{
|
||||
const Station *st = Station::Get(this->window_number);
|
||||
int y = r.top + WD_FRAMERECT_TOP;
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||
|
||||
if (st->town->exclusive_counter > 0) {
|
||||
SetDParam(0, st->town->exclusivity);
|
||||
y = DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, r.bottom, st->town->exclusivity == st->owner ? STR_STATION_VIEW_EXCLUSIVE_RIGHTS_SELF : STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY);
|
||||
y += WD_PAR_VSEP_WIDE;
|
||||
tr.top = DrawStringMultiLine(tr, st->town->exclusivity == st->owner ? STR_STATION_VIEW_EXCLUSIVE_RIGHTS_SELF : STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY);
|
||||
tr.top += WidgetDimensions::scaled.vsep_wide;
|
||||
}
|
||||
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_VIEW_SUPPLY_RATINGS_TITLE);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
DrawString(tr, STR_STATION_VIEW_SUPPLY_RATINGS_TITLE);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
|
||||
this->ratings_list_y = y;
|
||||
this->ratings_list_y = tr.top;
|
||||
for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
|
||||
const GoodsEntry *ge = &st->goods[cs->Index()];
|
||||
if (!ge->HasRating()) continue;
|
||||
@@ -1875,10 +1877,10 @@ struct StationViewWindow : public Window {
|
||||
SetDParam(1, lg != nullptr ? lg->Monthly((*lg)[ge->node].Supply()) : 0);
|
||||
SetDParam(2, STR_CARGO_RATING_APPALLING + (ge->rating >> 5));
|
||||
SetDParam(3, ToPercent8(ge->rating));
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT + 6, r.right - WD_FRAMERECT_RIGHT - 6, y, STR_STATION_VIEW_CARGO_SUPPLY_RATING);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
DrawString(tr.Indent(WidgetDimensions::scaled.hsep_indent, rtl), STR_STATION_VIEW_CARGO_SUPPLY_RATING);
|
||||
tr.top += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
return CeilDiv(y - r.top - WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL);
|
||||
return CeilDiv(tr.top - r.top - WidgetDimensions::scaled.framerect.top, FONT_HEIGHT_NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1920,7 +1922,7 @@ struct StationViewWindow : public Window {
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SV_WAITING:
|
||||
this->HandleCargoWaitingClick(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SV_WAITING, WD_FRAMERECT_TOP) - this->vscroll->GetPosition());
|
||||
this->HandleCargoWaitingClick(this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SV_WAITING, WidgetDimensions::scaled.framerect.top) - this->vscroll->GetPosition());
|
||||
break;
|
||||
|
||||
case WID_SV_CATCHMENT:
|
||||
@@ -2099,7 +2101,7 @@ struct StationViewWindow : public Window {
|
||||
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_SV_WAITING, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_SV_WAITING, WidgetDimensions::scaled.framerect.Vertical());
|
||||
}
|
||||
|
||||
bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
|
||||
@@ -2337,8 +2339,8 @@ struct SelectStationWindow : WindowPopup {
|
||||
|
||||
resize->height = d.height;
|
||||
d.height *= 5;
|
||||
d.width += WD_FRAMERECT_RIGHT + WD_FRAMERECT_LEFT;
|
||||
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = d;
|
||||
}
|
||||
|
||||
@@ -2346,20 +2348,20 @@ struct SelectStationWindow : WindowPopup {
|
||||
{
|
||||
if (widget != WID_JS_PANEL) return;
|
||||
|
||||
uint y = r.top + WD_FRAMERECT_TOP;
|
||||
Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
|
||||
if (this->vscroll->GetPosition() == 0) {
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
|
||||
y += this->resize.step_height;
|
||||
DrawString(tr, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
|
||||
tr.top += this->resize.step_height;
|
||||
}
|
||||
|
||||
for (uint i = std::max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.size(); ++i, y += this->resize.step_height) {
|
||||
for (uint i = std::max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.size(); ++i, tr.top += this->resize.step_height) {
|
||||
/* Don't draw anything if it extends past the end of the window. */
|
||||
if (i - this->vscroll->GetPosition() >= this->vscroll->GetCapacity()) break;
|
||||
|
||||
const T *st = T::Get(_stations_nearby_list[i - 1]);
|
||||
SetDParam(0, st->index);
|
||||
SetDParam(1, st->facilities);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION);
|
||||
DrawString(tr, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2367,7 +2369,7 @@ struct SelectStationWindow : WindowPopup {
|
||||
{
|
||||
if (widget != WID_JS_PANEL) return;
|
||||
|
||||
uint st_index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_JS_PANEL, WD_FRAMERECT_TOP);
|
||||
uint st_index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_JS_PANEL, WidgetDimensions::scaled.framerect.top);
|
||||
bool distant_join = (st_index > 0);
|
||||
if (distant_join) st_index--;
|
||||
|
||||
@@ -2390,7 +2392,7 @@ struct SelectStationWindow : WindowPopup {
|
||||
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_JS_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_JS_PANEL, WidgetDimensions::scaled.framerect.Vertical());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2414,7 +2416,7 @@ struct SelectStationWindow : WindowPopup {
|
||||
}
|
||||
|
||||
/* Show coverage area of station under cursor */
|
||||
uint st_index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_JS_PANEL, WD_FRAMERECT_TOP);
|
||||
uint st_index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_JS_PANEL, WidgetDimensions::scaled.framerect.top);
|
||||
if (st_index == 0 || st_index > _stations_nearby_list.size()) {
|
||||
SetViewportCatchmentStation(nullptr, true);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user