mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 06:41:51 +00:00
Switching GUI to an alternate font; using a second, bigger, font for 640x480 games like COMI. Note: we can always easily switch back to the SCUMM font or any other font, if we want to
svn-id: r16467
This commit is contained in:
parent
a9d0472758
commit
858c6c4d5b
@ -36,9 +36,8 @@ int NewFont::getCharWidth(byte chr) const {
|
||||
return desc.width[chr - desc.firstchar];
|
||||
}
|
||||
|
||||
void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, int scaleFactor) const {
|
||||
void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color) const {
|
||||
assert(dst != 0);
|
||||
tx *= scaleFactor; ty *= scaleFactor;
|
||||
|
||||
byte *ptr = (byte *)dst->getBasePtr(tx, ty);
|
||||
|
||||
@ -56,26 +55,15 @@ void NewFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 colo
|
||||
chr -= desc.firstchar;
|
||||
const bitmap_t *tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * desc.height));
|
||||
|
||||
for (int y = 0; y < desc.height * scaleFactor; y++, ptr += dst->pitch) {
|
||||
for (int y = 0; y < desc.height; y++, ptr += dst->pitch) {
|
||||
const bitmap_t *buffer = 0;
|
||||
if(scaleFactor != 1) {
|
||||
if(!(y % 2))
|
||||
buffer = tmp++;
|
||||
else
|
||||
buffer = tmp;
|
||||
} else
|
||||
buffer = tmp++;
|
||||
buffer = tmp++;
|
||||
bitmap_t mask = 0x8000;
|
||||
if (ty + y < 0 || ty + y >= dst->h)
|
||||
continue;
|
||||
|
||||
for (int x = 0; x < w * scaleFactor; x++) {
|
||||
if(scaleFactor != 1) {
|
||||
if(!(x % 2) && x != 0)
|
||||
mask >>= 1;
|
||||
} else if(x != 0) {
|
||||
mask >>= 1;
|
||||
}
|
||||
for (int x = 0; x < w; x++) {
|
||||
mask >>= 1;
|
||||
|
||||
if (tx + x < 0 || tx + x >= dst->w)
|
||||
continue;
|
||||
@ -101,7 +89,7 @@ int Font::getStringWidth(const Common::String &str) const {
|
||||
return space;
|
||||
}
|
||||
|
||||
void Font::drawString(const Surface *dst, const Common::String &s, int x, int y, int w, uint32 color, TextAlignment align, int deltax, bool useEllipsis, int scaleFactor) const {
|
||||
void Font::drawString(const Surface *dst, const Common::String &s, int x, int y, int w, uint32 color, TextAlignment align, int deltax, bool useEllipsis) const {
|
||||
assert(dst != 0);
|
||||
const int leftX = x, rightX = x + w;
|
||||
uint i;
|
||||
@ -166,7 +154,7 @@ void Font::drawString(const Surface *dst, const Common::String &s, int x, int y,
|
||||
if (x+w > rightX)
|
||||
break;
|
||||
if (x >= leftX)
|
||||
drawChar(dst, str[i], x, y, color, scaleFactor);
|
||||
drawChar(dst, str[i], x, y, color);
|
||||
x += w;
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,9 @@ public:
|
||||
virtual int getMaxCharWidth() const = 0;
|
||||
|
||||
virtual int getCharWidth(byte chr) const = 0;
|
||||
virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, int scaleFactor = 1) const = 0;
|
||||
virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const = 0;
|
||||
|
||||
void drawString(const Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlignment align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true, int scaleFactor = 1) const;
|
||||
void drawString(const Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlignment align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const;
|
||||
int getStringWidth(const Common::String &str) const;
|
||||
};
|
||||
|
||||
@ -65,7 +65,7 @@ public:
|
||||
virtual int getMaxCharWidth() const { return 8; };
|
||||
|
||||
virtual int getCharWidth(byte chr) const;
|
||||
virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, int scaleFactor) const;
|
||||
virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const;
|
||||
};
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ public:
|
||||
virtual int getMaxCharWidth() const { return desc.maxwidth; };
|
||||
|
||||
virtual int getCharWidth(byte chr) const;
|
||||
virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color, int scaleFactor) const;
|
||||
virtual void drawChar(const Surface *dst, byte chr, int x, int y, uint32 color) const;
|
||||
};
|
||||
|
||||
} // End of namespace Graphics
|
||||
|
@ -29,6 +29,7 @@ namespace Graphics {
|
||||
|
||||
const ScummFont g_scummfont;
|
||||
extern const NewFont g_sysfont;
|
||||
extern const NewFont g_sysfont_big;
|
||||
|
||||
|
||||
DECLARE_SINGLETON(FontManager);
|
||||
@ -46,7 +47,9 @@ const Font *FontManager::getFontByUsage(FontUsage usage) const {
|
||||
case kConsoleFont:
|
||||
return &GUI::g_consolefont;
|
||||
case kGUIFont:
|
||||
return &g_scummfont;
|
||||
return &g_sysfont;
|
||||
case kBigGUIFont:
|
||||
return &g_sysfont_big;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ public:
|
||||
enum FontUsage {
|
||||
kOSDFont,
|
||||
kConsoleFont,
|
||||
kGUIFont
|
||||
kGUIFont,
|
||||
kBigGUIFont
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,7 @@ MODULE_OBJS := \
|
||||
graphics/font.o \
|
||||
graphics/fontman.o \
|
||||
graphics/newfont.o \
|
||||
graphics/newfont_big.o \
|
||||
graphics/surface.o
|
||||
|
||||
MODULE_DIRS += \
|
||||
|
@ -63,9 +63,8 @@ int ScummFont::getCharWidth(byte chr) const {
|
||||
}
|
||||
|
||||
//void ScummFont::drawChar(byte chr, int xx, int yy, OverlayColor color) {
|
||||
void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color, int scaleFactor) const {
|
||||
void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 color) const {
|
||||
assert(dst != 0);
|
||||
tx *= scaleFactor; ty *= scaleFactor;
|
||||
|
||||
byte *ptr = (byte *)dst->getBasePtr(tx, ty);
|
||||
|
||||
@ -73,25 +72,18 @@ void ScummFont::drawChar(const Surface *dst, byte chr, int tx, int ty, uint32 co
|
||||
uint buffer = 0;
|
||||
uint mask = 0;
|
||||
|
||||
for (int y = 0; y < 8 * scaleFactor; y++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
if (ty + y < 0 || ty + y >= dst->h)
|
||||
continue;
|
||||
for (int x = 0; x < 8 * scaleFactor; x++) {
|
||||
if(scaleFactor != 1 && !(x % 2))
|
||||
mask >>= 1;
|
||||
else if(scaleFactor == 1)
|
||||
mask >>= 1;
|
||||
for (int x = 0; x < 8; x++) {
|
||||
mask >>= 1;
|
||||
|
||||
if (tx + x < 0 || tx + x >= dst->w)
|
||||
continue;
|
||||
|
||||
|
||||
if (mask == 0) {
|
||||
if(scaleFactor != 1 && !(y % 2))
|
||||
buffer = *tmp++;
|
||||
else if(scaleFactor == 1)
|
||||
buffer = *tmp++;
|
||||
|
||||
buffer = *tmp++;
|
||||
mask = 0x80;
|
||||
}
|
||||
const byte c = ((buffer & mask) != 0);
|
||||
|
@ -86,7 +86,7 @@ AboutDialog::AboutDialog()
|
||||
|
||||
int i;
|
||||
|
||||
_lineHeight = g_gui.getFont().getFontHeight() + 3;
|
||||
_lineHeight = g_gui.getFontHeight() + 3;
|
||||
|
||||
for (i = 0; i < 1; i++)
|
||||
_lines.push_back("");
|
||||
|
@ -86,8 +86,11 @@ void NewGui::updateScaleFactor() {
|
||||
|
||||
_scaleFactor = MIN(_system->getWidth() / kDefaultGUIWidth, _system->getHeight() / kDefaultGUIHeight);
|
||||
|
||||
// TODO: Pick a bigger font depending on the 'scale' factor.
|
||||
_font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
|
||||
// Pick the font depending on the scale factor.
|
||||
if (_scaleFactor == 1)
|
||||
_font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
|
||||
else
|
||||
_font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
|
||||
}
|
||||
|
||||
void NewGui::runLoop() {
|
||||
@ -349,19 +352,23 @@ void NewGui::addDirtyRect(int x, int y, int w, int h) {
|
||||
void NewGui::drawChar(byte chr, int xx, int yy, OverlayColor color, const Graphics::Font *font) {
|
||||
if (font == 0)
|
||||
font = &getFont();
|
||||
font->drawChar(&_screen, chr, xx, yy, color, _scaleFactor);
|
||||
font->drawChar(&_screen, chr, xx * _scaleFactor, yy * _scaleFactor, color);
|
||||
}
|
||||
|
||||
int NewGui::getStringWidth(const String &str) {
|
||||
return getFont().getStringWidth(str);
|
||||
int NewGui::getStringWidth(const String &str) const {
|
||||
return getFont().getStringWidth(str) / _scaleFactor;
|
||||
}
|
||||
|
||||
int NewGui::getCharWidth(byte c) {
|
||||
return getFont().getCharWidth(c);
|
||||
int NewGui::getCharWidth(byte c) const {
|
||||
return getFont().getCharWidth(c) / _scaleFactor;
|
||||
}
|
||||
|
||||
int NewGui::getFontHeight() const {
|
||||
return getFont().getFontHeight() / _scaleFactor;
|
||||
}
|
||||
|
||||
void NewGui::drawString(const String &s, int x, int y, int w, OverlayColor color, TextAlignment align, int deltax, bool useEllipsis) {
|
||||
getFont().drawString(&_screen, s, x, y, w, color, align, deltax, useEllipsis, _scaleFactor);
|
||||
getFont().drawString(&_screen, s, x * _scaleFactor, y * _scaleFactor, w * _scaleFactor, color, align, deltax, useEllipsis);
|
||||
}
|
||||
|
||||
//
|
||||
|
11
gui/newgui.h
11
gui/newgui.h
@ -36,7 +36,7 @@ class Dialog;
|
||||
|
||||
|
||||
// Height of a single text line
|
||||
#define kLineHeight (g_gui.getFont().getFontHeight() + 2)
|
||||
#define kLineHeight (g_gui.getFontHeight() + 2)
|
||||
|
||||
|
||||
using Graphics::TextAlignment;
|
||||
@ -64,9 +64,9 @@ public:
|
||||
// until no dialogs are active anymore.
|
||||
void runLoop();
|
||||
|
||||
bool isActive() { return ! _dialogStack.empty(); }
|
||||
bool isActive() const { return ! _dialogStack.empty(); }
|
||||
|
||||
int getScaleFactor() { return _scaleFactor; }
|
||||
int getScaleFactor() const { return _scaleFactor; }
|
||||
void enableScaling(bool enable) { _scaleEnable = enable; updateScaleFactor(); }
|
||||
|
||||
protected:
|
||||
@ -140,8 +140,9 @@ public:
|
||||
void drawChar(byte c, int x, int y, OverlayColor color, const Graphics::Font *font = 0);
|
||||
void drawString(const String &str, int x, int y, int w, OverlayColor color, Graphics::TextAlignment align = Graphics::kTextAlignLeft, int deltax = 0, bool useEllipsis = true);
|
||||
|
||||
int getStringWidth(const String &str);
|
||||
int getCharWidth(byte c);
|
||||
int getStringWidth(const String &str) const;
|
||||
int getCharWidth(byte c) const;
|
||||
int getFontHeight() const;
|
||||
|
||||
void drawBitmap(uint32 *bitmap, int x, int y, OverlayColor color, int h = 8);
|
||||
|
||||
|
@ -186,12 +186,11 @@ void CheckboxWidget::drawWidget(bool hilite) {
|
||||
|
||||
// Draw the box
|
||||
gui->box(_x, _y, 14, 14, gui->_color, gui->_shadowcolor);
|
||||
gui->fillRect(_x + 2, _y + 2, 10, 10, gui->_bgcolor);
|
||||
|
||||
// If checked, draw cross inside the box
|
||||
if (_state)
|
||||
gui->drawBitmap(checked_img, _x + 3, _y + 3, isEnabled() ? gui->_textcolor : gui->_color);
|
||||
else
|
||||
gui->fillRect(_x + 2, _y + 2, 10, 10, gui->_bgcolor);
|
||||
gui->drawBitmap(checked_img, _x + 4, _y + 3, isEnabled() ? gui->_textcolor : gui->_color);
|
||||
|
||||
// Finally draw the label
|
||||
gui->drawString(_label, _x + 20, _y + 3, _w, isEnabled() ? gui->_textcolor : gui->_color);
|
||||
|
Loading…
x
Reference in New Issue
Block a user