mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
(svn r17008) -Fix [FS#3061]: Resize matrix in station build window vertically according to font height.
This commit is contained in:
parent
8181a0a2ad
commit
b129184d57
@ -1000,7 +1000,6 @@ private:
|
||||
public:
|
||||
BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(parent)
|
||||
{
|
||||
this->line_height = FONT_HEIGHT_NORMAL + 4;
|
||||
this->InitNested(desc, TRANSPORT_RAIL);
|
||||
|
||||
this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
|
||||
@ -1019,7 +1018,7 @@ public:
|
||||
_railstation.station_count = GetNumCustomStations(_railstation.station_class);
|
||||
|
||||
this->vscroll.count = _railstation.station_count;
|
||||
this->vscroll.cap = 5;
|
||||
this->vscroll.cap = GB(this->nested_array[BRSW_NEWST_LIST]->widget_data, MAT_ROW_START, MAT_ROW_BITS);
|
||||
this->vscroll.pos = Clamp(_railstation.station_type - 2, 0, this->vscroll.count - this->vscroll.cap);
|
||||
} else {
|
||||
/* New stations are not available, so ensure the default station
|
||||
@ -1082,8 +1081,8 @@ public:
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize)
|
||||
{
|
||||
if (widget != BRSW_NEWST_DROPDOWN) return;
|
||||
|
||||
switch (widget) {
|
||||
case BRSW_NEWST_DROPDOWN: {
|
||||
Dimension d = {0, 0};
|
||||
for (uint i = 0; i < GetNumStationClasses(); i++) {
|
||||
if (i == STAT_CLASS_WAYP) continue;
|
||||
@ -1093,6 +1092,15 @@ public:
|
||||
d.width += padding.width;
|
||||
d.height += padding.height;
|
||||
*size = maxdim(*size, d);
|
||||
break;
|
||||
}
|
||||
case BRSW_NEWST_LIST: {
|
||||
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
|
||||
|
||||
size->height = GB(this->nested_array[widget]->widget_data, MAT_ROW_START, MAT_ROW_BITS) * this->line_height;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
@ -1125,19 +1133,18 @@ public:
|
||||
break;
|
||||
|
||||
case BRSW_NEWST_LIST: {
|
||||
uint y = r.top + 3;
|
||||
uint y = r.top;
|
||||
for (uint16 i = this->vscroll.pos; i < _railstation.station_count && i < (uint)(this->vscroll.pos + this->vscroll.cap); i++) {
|
||||
const StationSpec *statspec = GetCustomStationSpec(_railstation.station_class, i);
|
||||
|
||||
StringID str = STR_STAT_CLASS_DFLT;
|
||||
if (statspec != NULL && statspec->name != 0) {
|
||||
if (HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && GB(GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE), 0, 8) == 0) {
|
||||
GfxFillRect(r.left + 1, y - 2, r.right - 1, y + FONT_HEIGHT_NORMAL, 0, FILLRECT_CHECKER);
|
||||
GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->line_height - 2, 0, FILLRECT_CHECKER);
|
||||
}
|
||||
|
||||
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, statspec->name, i == _railstation.station_type ? TC_WHITE : TC_BLACK);
|
||||
} else {
|
||||
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STAT_CLASS_DFLT, i == _railstation.station_type ? TC_WHITE : TC_BLACK);
|
||||
str = statspec->name;
|
||||
}
|
||||
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, str, i == _railstation.station_type ? TC_WHITE : TC_BLACK);
|
||||
|
||||
y += this->line_height;
|
||||
}
|
||||
|
@ -60,6 +60,12 @@ enum WidgetDrawDistances {
|
||||
WD_FRAMETEXT_LEFT = 6, ///< Left offset of the text of the frame.
|
||||
WD_FRAMETEXT_RIGHT = 6, ///< Right offset of the text of the frame.
|
||||
|
||||
/* WWT_MATRIX */
|
||||
WD_MATRIX_LEFT = 2, ///< Offset at left of a matrix cell.
|
||||
WD_MATRIX_RIGHT = 2, ///< Offset at right of a matrix cell.
|
||||
WD_MATRIX_TOP = 3, ///< Offset at top of a matrix cell.
|
||||
WD_MATRIX_BOTTOM = 1, ///< Offset at bottom of a matrix cell.
|
||||
|
||||
/* WWT_STICKYBOX */
|
||||
WD_STICKYBOX_WIDTH = 12, ///< Width of a standard sticky box widget.
|
||||
WD_STICKYBOX_LEFT = 2, ///< Left offset of sticky sprite.
|
||||
|
Loading…
Reference in New Issue
Block a user