GUI: Use a truetype font for the debug console

This commit is contained in:
Bastien Bouclet 2019-04-27 08:00:37 +02:00
parent 2a38562d4b
commit a5d93d933a
15 changed files with 57 additions and 18 deletions

Binary file not shown.

View file

@ -37,7 +37,7 @@
#include "graphics/pixelformat.h" #include "graphics/pixelformat.h"
#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.26" #define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.8.27"
class OSystem; class OSystem;
@ -131,6 +131,7 @@ enum TextData {
kTextDataButton, kTextDataButton,
kTextDataNormalFont, kTextDataNormalFont,
kTextDataTooltip, kTextDataTooltip,
kTextDataConsole,
kTextDataMAX kTextDataMAX
}; };
@ -220,6 +221,7 @@ public:
kFontStyleFixedBold = 4, ///< Fixed size bold font. kFontStyleFixedBold = 4, ///< Fixed size bold font.
kFontStyleFixedItalic = 5, ///< Fixed size italic font. kFontStyleFixedItalic = 5, ///< Fixed size italic font.
kFontStyleTooltip = 6, ///< Tiny console font kFontStyleTooltip = 6, ///< Tiny console font
kFontStyleConsole = 7, ///< Debug console font
kFontStyleMax kFontStyleMax
}; };
@ -361,6 +363,8 @@ public:
return kTextDataNormalFont; return kTextDataNormalFont;
if (font == kFontStyleTooltip) if (font == kFontStyleTooltip)
return kTextDataTooltip; return kTextDataTooltip;
if (font == kFontStyleConsole)
return kTextDataConsole;
return kTextDataDefault; return kTextDataDefault;
} }

View file

@ -40,7 +40,8 @@ static const TextDataInfo kTextDataDefaults[] = {
{ kTextDataDefault, "text_default" }, { kTextDataDefault, "text_default" },
{ kTextDataButton, "text_button" }, { kTextDataButton, "text_button" },
{ kTextDataNormalFont, "text_normal" }, { kTextDataNormalFont, "text_normal" },
{ kTextDataTooltip, "tooltip_normal" } { kTextDataTooltip, "tooltip_normal" },
{ kTextDataConsole, "console" }
}; };

View file

@ -33,8 +33,8 @@
namespace GUI { namespace GUI {
#define kConsoleCharWidth (_font->getMaxCharWidth()) #define kConsoleCharWidth (_font->getCharWidth('M'))
#define kConsoleLineHeight (_font->getFontHeight() + 2) #define kConsoleLineHeight (_font->getFontHeight())
enum { enum {
kConsoleSlideDownDuration = 200 // Time in milliseconds kConsoleSlideDownDuration = 200 // Time in milliseconds
@ -93,8 +93,7 @@ void ConsoleDialog::init() {
const int screenW = g_system->getOverlayWidth(); const int screenW = g_system->getOverlayWidth();
const int screenH = g_system->getOverlayHeight(); const int screenH = g_system->getOverlayHeight();
_font = FontMan.getFontByUsage((Graphics::FontManager::FontUsage) _font = &g_gui.getFont(ThemeEngine::kFontStyleConsole);
g_gui.xmlEval()->getVar("Console.Font", Graphics::FontManager::kConsoleFont));
_leftPadding = g_gui.xmlEval()->getVar("Globals.Console.Padding.Left", 0); _leftPadding = g_gui.xmlEval()->getVar("Globals.Console.Padding.Left", 0);
_rightPadding = g_gui.xmlEval()->getVar("Globals.Console.Padding.Right", 0); _rightPadding = g_gui.xmlEval()->getVar("Globals.Console.Padding.Right", 0);
@ -167,10 +166,10 @@ void ConsoleDialog::drawDialog(DrawLayer layerToDraw) {
Dialog::drawDialog(layerToDraw); Dialog::drawDialog(layerToDraw);
for (int line = 0; line < _linesPerPage; line++) for (int line = 0; line < _linesPerPage; line++)
drawLine(line, false); drawLine(line);
} }
void ConsoleDialog::drawLine(int line, bool restoreBg) { void ConsoleDialog::drawLine(int line) {
int x = _x + 1 + _leftPadding; int x = _x + 1 + _leftPadding;
int start = _scrollLine - _linesPerPage + 1; int start = _scrollLine - _linesPerPage + 1;
int y = _y + 2 + _topPadding; int y = _y + 2 + _topPadding;
@ -178,11 +177,6 @@ void ConsoleDialog::drawLine(int line, bool restoreBg) {
y += line * kConsoleLineHeight; y += line * kConsoleLineHeight;
if (restoreBg) {
Common::Rect r(_x, y - 2, _x + _pageWidth * kConsoleCharWidth, y+kConsoleLineHeight);
g_gui.theme()->restoreBackground(r);
}
for (int column = 0; column < limit; column++) { for (int column = 0; column < limit; column++) {
#if 0 #if 0
int l = (start + line) % _linesInBuffer; int l = (start + line) % _linesInBuffer;
@ -726,7 +720,7 @@ void ConsoleDialog::drawCaret(bool erase) {
} }
int x = _x + 1 + _leftPadding + (_currentPos % kCharsPerLine) * kConsoleCharWidth; int x = _x + 1 + _leftPadding + (_currentPos % kCharsPerLine) * kConsoleCharWidth;
int y = _y + _topPadding + displayLine * kConsoleLineHeight; int y = _y + 2 + _topPadding + displayLine * kConsoleLineHeight;
_caretVisible = !erase; _caretVisible = !erase;
g_gui.theme()->drawCaret(Common::Rect(x, y, x + 1, y + kConsoleLineHeight), erase); g_gui.theme()->drawCaret(Common::Rect(x, y, x + 1, y + kConsoleLineHeight), erase);

View file

@ -167,7 +167,7 @@ protected:
int pos2line(int pos) { return (pos - (_scrollLine - _linesPerPage + 1) * kCharsPerLine) / kCharsPerLine; } int pos2line(int pos) { return (pos - (_scrollLine - _linesPerPage + 1) * kCharsPerLine) / kCharsPerLine; }
void drawLine(int line, bool restoreBg = true); void drawLine(int line);
void drawCaret(bool erase); void drawCaret(bool erase);
void printCharIntern(int c); void printCharIntern(int c);
void insertIntoPrompt(const char *str); void insertIntoPrompt(const char *str);

View file

@ -43,6 +43,9 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"<font id='tooltip_normal' " "<font id='tooltip_normal' "
"file='fixed5x8.bdf' " "file='fixed5x8.bdf' "
"/>" "/>"
"<font id='console' "
"file='builtinConsole' "
"/>"
"<text_color id='color_normal' " "<text_color id='color_normal' "
"color='green' " "color='green' "
"/>" "/>"

Binary file not shown.

View file

@ -1 +1 @@
[SCUMMVM_STX0.8.26:ScummVM Classic Theme:No Author] [SCUMMVM_STX0.8.27:ScummVM Classic Theme:No Author]

View file

@ -64,6 +64,9 @@
<font id = 'tooltip_normal' <font id = 'tooltip_normal'
file = 'fixed5x8.bdf' file = 'fixed5x8.bdf'
/> />
<font id = 'console'
file = 'builtinConsole'
/>
<text_color id = 'color_normal' <text_color id = 'color_normal'
color = 'green' color = 'green'

Binary file not shown.

View file

@ -1 +1 @@
[SCUMMVM_STX0.8.26:ScummVM Modern Theme:No Author] [SCUMMVM_STX0.8.27:ScummVM Modern Theme:No Author]

View file

@ -161,6 +161,23 @@
scalable_file = 'FreeMonoBold.ttf' scalable_file = 'FreeMonoBold.ttf'
point_size = '8' point_size = '8'
/> />
<font id = 'console'
file = 'builtinConsole'
scalable_file = 'SourceCodeVariable-Roman.ttf'
point_size = '12'
/>
<font resolution = 'y<800'
id = 'console'
file = 'builtinConsole'
scalable_file = 'SourceCodeVariable-Roman.ttf'
point_size = '10'
/>
<font resolution = 'y<400'
id = 'console'
file = 'builtinConsole'
scalable_file = 'SourceCodeVariable-Roman.ttf'
point_size = '8'
/>
<text_color id = 'color_normal' <text_color id = 'color_normal'
color = 'black' color = 'black'

Binary file not shown.

View file

@ -1 +1 @@
[SCUMMVM_STX0.8.26:ScummVM Modern Theme Remastered:No Author] [SCUMMVM_STX0.8.27:ScummVM Modern Theme Remastered:No Author]

View file

@ -162,6 +162,23 @@
scalable_file = 'FreeSans.ttf' scalable_file = 'FreeSans.ttf'
point_size = '11' point_size = '11'
/> />
<font id = 'console'
file = 'builtinConsole'
scalable_file = 'SourceCodeVariable-Roman.ttf'
point_size = '12'
/>
<font resolution = 'y<800'
id = 'console'
file = 'builtinConsole'
scalable_file = 'SourceCodeVariable-Roman.ttf'
point_size = '10'
/>
<font resolution = 'y<400'
id = 'console'
file = 'builtinConsole'
scalable_file = 'SourceCodeVariable-Roman.ttf'
point_size = '8'
/>
<text_color id = 'color_normal' <text_color id = 'color_normal'
color = 'black' color = 'black'