|
@@ -842,22 +842,22 @@ void SmallMapWindow::DrawSmallMapColumn(
|
|
|
|
|
|
/* Construct tilearea covered by (xc, yc, xc + this->zoom, yc + this->zoom) such that it is within min_xy limits. */
|
|
|
TileArea ta;
|
|
|
if (min_xy == 1 && (xc == 0 || yc == 0)) {
|
|
|
if (this->zoom == 1) continue; // The tile area is empty, don't draw anything.
|
|
|
|
|
|
ta = TileArea(TileXY(max(min_xy, xc), max(min_xy, yc)), this->zoom - (xc == 0), this->zoom - (yc == 0));
|
|
|
ta = TileArea(TileXY(std::max(min_xy, xc), std::max(min_xy, yc)), this->zoom - (xc == 0), this->zoom - (yc == 0));
|
|
|
} else {
|
|
|
ta = TileArea(TileXY(xc, yc), this->zoom, this->zoom);
|
|
|
}
|
|
|
ta.ClampToMap(); // Clamp to map boundaries (may contain MP_VOID tiles!).
|
|
|
|
|
|
uint32 val = this->GetTileColours(ta);
|
|
|
uint8 *val8 = (uint8 *)&val;
|
|
|
int idx = max(0, -start_pos);
|
|
|
for (int pos = max(0, start_pos); pos < end_pos; pos++) {
|
|
|
int idx = std::max(0, -start_pos);
|
|
|
for (int pos = std::max(0, start_pos); pos < end_pos; pos++) {
|
|
|
blitter->SetPixel(dst, idx, 0, val8[idx]);
|
|
|
idx++;
|
|
|
}
|
|
|
/* Switch to next tile in the column */
|
|
|
} while (xc += this->zoom, yc += this->zoom, dst = blitter->MoveTo(dst, pitch, 0), --reps != 0);
|
|
|
}
|
|
@@ -983,13 +983,13 @@ void SmallMapWindow::DrawSmallMap(DrawPi
|
|
|
|
|
|
for (;;) {
|
|
|
/* Distance from left edge */
|
|
|
if (x >= -3) {
|
|
|
if (x >= dpi->width) break; // Exit the loop.
|
|
|
|
|
|
int end_pos = min(dpi->width, x + 4);
|
|
|
int end_pos = std::min(dpi->width, x + 4);
|
|
|
int reps = (dpi->height - y + 1) / 2; // Number of lines.
|
|
|
if (reps > 0) {
|
|
|
this->DrawSmallMapColumn(ptr, tile_x, tile_y, dpi->pitch * 2, reps, x, end_pos, blitter);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1156,23 +1156,23 @@ void SmallMapWindow::RebuildColourIndexI
|
|
|
str = STR_SMALLMAP_COMPANY;
|
|
|
} else {
|
|
|
str = tbl->legend;
|
|
|
}
|
|
|
} else {
|
|
|
if (tbl->col_break) {
|
|
|
this->min_number_of_fixed_rows = max(this->min_number_of_fixed_rows, height);
|
|
|
this->min_number_of_fixed_rows = std::max(this->min_number_of_fixed_rows, height);
|
|
|
height = 0;
|
|
|
num_columns++;
|
|
|
}
|
|
|
height++;
|
|
|
str = tbl->legend;
|
|
|
}
|
|
|
min_width = max(GetStringBoundingBox(str).width, min_width);
|
|
|
min_width = std::max(GetStringBoundingBox(str).width, min_width);
|
|
|
}
|
|
|
this->min_number_of_fixed_rows = max(this->min_number_of_fixed_rows, height);
|
|
|
this->min_number_of_columns = max(this->min_number_of_columns, num_columns);
|
|
|
this->min_number_of_fixed_rows = std::max(this->min_number_of_fixed_rows, height);
|
|
|
this->min_number_of_columns = std::max(this->min_number_of_columns, num_columns);
|
|
|
}
|
|
|
|
|
|
/* The width of a column is the minimum width of all texts + the size of the blob + some spacing */
|
|
|
this->column_width = min_width + LEGEND_BLOB_WIDTH + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
|
|
}
|
|
|
|
|
@@ -1314,14 +1314,14 @@ void SmallMapWindow::SwitchMapType(Small
|
|
|
* @return Number of rows needed for everything to fit in.
|
|
|
*/
|
|
|
inline uint SmallMapWindow::GetNumberRowsLegend(uint columns) const
|
|
|
{
|
|
|
/* Reserve one column for link colours */
|
|
|
uint num_rows_linkstats = CeilDiv(_smallmap_cargo_count, columns - 1);
|
|
|
uint num_rows_others = CeilDiv(max(_smallmap_industry_count, _smallmap_company_count), columns);
|
|
|
return max(this->min_number_of_fixed_rows, max(num_rows_linkstats, num_rows_others));
|
|
|
uint num_rows_others = CeilDiv(std::max(_smallmap_industry_count, _smallmap_company_count), columns);
|
|
|
return std::max({this->min_number_of_fixed_rows, num_rows_linkstats, num_rows_others});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Select and toggle a legend item. When CTRL is pressed, disable all other
|
|
|
* items in the group defined by begin_legend_item and end_legend_item and
|
|
|
* keep the clicked one enabled even if it was already enabled before. If
|
|
@@ -1649,13 +1649,13 @@ void SmallMapWindow::SmallMapCenterOnCur
|
|
|
const Viewport *vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport;
|
|
|
Point viewport_center = InverseRemapCoords2(vp->virtual_left + vp->virtual_width / 2, vp->virtual_top + vp->virtual_height / 2);
|
|
|
|
|
|
int sub;
|
|
|
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);
|
|
|
Point sxy = this->ComputeScroll(viewport_center.x / (int)TILE_SIZE, viewport_center.y / (int)TILE_SIZE,
|
|
|
max(0, (int)wid->current_x / 2 - 2), wid->current_y / 2, &sub);
|
|
|
std::max(0, (int)wid->current_x / 2 - 2), wid->current_y / 2, &sub);
|
|
|
this->SetNewScroll(sxy.x, sxy.y, sub);
|
|
|
this->SetDirty();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the center of the given station as point on the screen in the smallmap window.
|
|
@@ -1702,18 +1702,18 @@ public:
|
|
|
|
|
|
display->SetupSmallestSize(w, init_array);
|
|
|
bar->SetupSmallestSize(w, init_array);
|
|
|
|
|
|
this->smallmap_window = dynamic_cast<SmallMapWindow *>(w);
|
|
|
assert(this->smallmap_window != nullptr);
|
|
|
this->smallest_x = max(display->smallest_x, bar->smallest_x + smallmap_window->GetMinLegendWidth());
|
|
|
this->smallest_y = display->smallest_y + max(bar->smallest_y, smallmap_window->GetLegendHeight(smallmap_window->min_number_of_columns));
|
|
|
this->fill_x = max(display->fill_x, bar->fill_x);
|
|
|
this->fill_y = (display->fill_y == 0 && bar->fill_y == 0) ? 0 : min(display->fill_y, bar->fill_y);
|
|
|
this->resize_x = max(display->resize_x, bar->resize_x);
|
|
|
this->resize_y = min(display->resize_y, bar->resize_y);
|
|
|
this->smallest_x = std::max(display->smallest_x, bar->smallest_x + smallmap_window->GetMinLegendWidth());
|
|
|
this->smallest_y = display->smallest_y + std::max(bar->smallest_y, smallmap_window->GetLegendHeight(smallmap_window->min_number_of_columns));
|
|
|
this->fill_x = std::max(display->fill_x, bar->fill_x);
|
|
|
this->fill_y = (display->fill_y == 0 && bar->fill_y == 0) ? 0 : std::min(display->fill_y, bar->fill_y);
|
|
|
this->resize_x = std::max(display->resize_x, bar->resize_x);
|
|
|
this->resize_y = std::min(display->resize_y, bar->resize_y);
|
|
|
}
|
|
|
|
|
|
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
|
|
|
{
|
|
|
this->pos_x = x;
|
|
|
this->pos_y = y;
|
|
@@ -1728,13 +1728,13 @@ public:
|
|
|
this->smallest_y = given_height;
|
|
|
/* Make display and bar exactly equal to their minimal size. */
|
|
|
display->AssignSizePosition(ST_SMALLEST, x, y, display->smallest_x, display->smallest_y, rtl);
|
|
|
bar->AssignSizePosition(ST_SMALLEST, x, y + display->smallest_y, bar->smallest_x, bar->smallest_y, rtl);
|
|
|
}
|
|
|
|
|
|
uint bar_height = max(bar->smallest_y, this->smallmap_window->GetLegendHeight(this->smallmap_window->GetNumberColumnsLegend(given_width - bar->smallest_x)));
|
|
|
uint bar_height = std::max(bar->smallest_y, this->smallmap_window->GetLegendHeight(this->smallmap_window->GetNumberColumnsLegend(given_width - bar->smallest_x)));
|
|
|
uint display_height = given_height - bar_height;
|
|
|
display->AssignSizePosition(ST_RESIZE, x, y, given_width, display_height, rtl);
|
|
|
bar->AssignSizePosition(ST_RESIZE, x, y + display_height, given_width, bar_height, rtl);
|
|
|
}
|
|
|
|
|
|
NWidgetCore *GetWidgetFromPos(int x, int y) override
|