mirror of https://github.com/OpenTTD/OpenTTD
(svn r18575) -Fix [FS#3393]: unit numbers weren't always fully shown in the depot
parent
f2785ae24d
commit
90b7f0f3cb
|
@ -631,15 +631,14 @@ struct DepotWindow : Window {
|
||||||
this->count_width = 0;
|
this->count_width = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDParam(0, 999);
|
Dimension unumber = { GetDigitWidth() * 4, FONT_HEIGHT_NORMAL };
|
||||||
Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);
|
|
||||||
const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
|
const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
|
||||||
this->flag_width = spr->width + WD_FRAMERECT_RIGHT;
|
this->flag_width = spr->width + WD_FRAMERECT_RIGHT;
|
||||||
this->flag_height = spr->height;
|
this->flag_height = spr->height;
|
||||||
|
|
||||||
if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
|
if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
|
||||||
min_height = max<uint>(unumber.height + WD_MATRIX_TOP, spr->height);
|
min_height = max<uint>(unumber.height + WD_MATRIX_TOP, spr->height);
|
||||||
this->header_width = unumber.width + this->flag_width;
|
this->header_width = unumber.width + this->flag_width + WD_FRAMERECT_LEFT;
|
||||||
} else {
|
} else {
|
||||||
min_height = unumber.height + spr->height + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
|
min_height = unumber.height + spr->height + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
|
||||||
this->header_width = max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT;
|
this->header_width = max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT;
|
||||||
|
|
14
src/gfx.cpp
14
src/gfx.cpp
|
@ -1306,6 +1306,20 @@ byte GetCharacterWidth(FontSize size, WChar key)
|
||||||
return GetGlyphWidth(size, key);
|
return GetGlyphWidth(size, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the maximum width of single digit.
|
||||||
|
* @param size Font of the digit
|
||||||
|
* @return Width of the digit.
|
||||||
|
*/
|
||||||
|
byte GetDigitWidth(FontSize size)
|
||||||
|
{
|
||||||
|
byte width = 0;
|
||||||
|
for (char c = '0'; c <= '9'; c++) {
|
||||||
|
width = max(GetCharacterWidth(size, c), width);
|
||||||
|
}
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ScreenSizeChanged()
|
void ScreenSizeChanged()
|
||||||
{
|
{
|
||||||
|
|
|
@ -160,6 +160,7 @@ bool ToggleFullScreen(bool fs);
|
||||||
extern FontSize _cur_fontsize; ///< Currently selected font.
|
extern FontSize _cur_fontsize; ///< Currently selected font.
|
||||||
|
|
||||||
byte GetCharacterWidth(FontSize size, uint32 key);
|
byte GetCharacterWidth(FontSize size, uint32 key);
|
||||||
|
byte GetDigitWidth(FontSize size = FS_NORMAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get height of a character for a given font size.
|
* Get height of a character for a given font size.
|
||||||
|
|
Loading…
Reference in New Issue