Changeset - r14022:b29f3a76f3c3
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-12-20 16:42:35
rubidium@openttd.org
(svn r18575) -Fix [FS#3393]: unit numbers weren't always fully shown in the depot
3 files changed with 17 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -628,21 +628,20 @@ struct DepotWindow : Window {
 
					SetDParam(0, 100);
 
					this->count_width = GetStringBoundingBox(STR_TINY_BLACK_COMA).width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				} else {
 
					this->count_width = 0;
 
				}
 

	
 
				SetDParam(0, 999);
 
				Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);
 
				Dimension unumber = { GetDigitWidth() * 4, FONT_HEIGHT_NORMAL };
 
				const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
 
				this->flag_width  = spr->width + WD_FRAMERECT_RIGHT;
 
				this->flag_height = spr->height;
 

	
 
				if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
 
					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 {
 
					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;
 
				}
 
				int base_width = this->count_width + this->header_width;
 

	
src/gfx.cpp
Show inline comments
 
@@ -1303,12 +1303,26 @@ byte GetCharacterWidth(FontSize size, WC
 
	/* Use _stringwidth_table cache if possible */
 
	if (key >= 32 && key < 256) return _stringwidth_table[size][key - 32];
 

	
 
	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()
 
{
 
	_dirty_bytes_per_line = (_screen.width + DIRTY_BLOCK_WIDTH - 1) / DIRTY_BLOCK_WIDTH;
 
	_dirty_blocks = ReallocT<byte>(_dirty_blocks, _dirty_bytes_per_line * ((_screen.height + DIRTY_BLOCK_HEIGHT - 1) / DIRTY_BLOCK_HEIGHT));
 

	
src/gfx_func.h
Show inline comments
 
@@ -157,12 +157,13 @@ void SortResolutions(int count);
 
bool ToggleFullScreen(bool fs);
 

	
 
/* gfx.cpp */
 
extern FontSize _cur_fontsize; ///< Currently selected font.
 

	
 
byte GetCharacterWidth(FontSize size, uint32 key);
 
byte GetDigitWidth(FontSize size = FS_NORMAL);
 

	
 
/**
 
 * Get height of a character for a given font size.
 
 * @param size Font size to get height of
 
 * @return     Height of characters in the given font (pixels)
 
 */
0 comments (0 inline, 0 general)