|
@@ -1668,48 +1668,66 @@ void LoadStringWidthTable(bool monospace
|
|
|
* @return Width of the character glyph
|
|
|
*/
|
|
|
byte GetCharacterWidth(FontSize size, WChar key)
|
|
|
{
|
|
|
/* 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;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Return the digit with the biggest width.
|
|
|
* @param size Font of the digit
|
|
|
* @return Broadest digit.
|
|
|
*/
|
|
|
uint GetBroadestDigit(FontSize size)
|
|
|
{
|
|
|
uint digit = 0;
|
|
|
byte width = 0;
|
|
|
for (char c = '0'; c <= '9'; c++) {
|
|
|
byte w = GetCharacterWidth(size, c);
|
|
|
if (w > width) {
|
|
|
width = w;
|
|
|
digit = c - '0';
|
|
|
}
|
|
|
}
|
|
|
return digit;
|
|
|
}
|
|
|
|
|
|
void ScreenSizeChanged()
|
|
|
{
|
|
|
_dirty_bytes_per_line = CeilDiv(_screen.width, DIRTY_BLOCK_WIDTH);
|
|
|
_dirty_blocks = ReallocT<byte>(_dirty_blocks, _dirty_bytes_per_line * CeilDiv(_screen.height, DIRTY_BLOCK_HEIGHT));
|
|
|
|
|
|
/* check the dirty rect */
|
|
|
if (_invalid_rect.right >= _screen.width) _invalid_rect.right = _screen.width;
|
|
|
if (_invalid_rect.bottom >= _screen.height) _invalid_rect.bottom = _screen.height;
|
|
|
|
|
|
/* screen size changed and the old bitmap is invalid now, so we don't want to undraw it */
|
|
|
_cursor.visible = false;
|
|
|
}
|
|
|
|
|
|
void UndrawMouseCursor()
|
|
|
{
|
|
|
/* Don't undraw the mouse cursor if the screen is not ready */
|
|
|
if (_screen.dst_ptr == NULL) return;
|
|
|
|
|
|
if (_cursor.visible) {
|
|
|
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter();
|
|
|
_cursor.visible = false;
|
|
|
blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, _cursor.draw_pos.x, _cursor.draw_pos.y), _cursor_backup.GetBuffer(), _cursor.draw_size.x, _cursor.draw_size.y);
|
|
|
_video_driver->MakeDirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
|