aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2005-01-06 22:48:42 +0000
committerMax Horn2005-01-06 22:48:42 +0000
commit858c6c4d5bb40a29550009b07f8d4b583d3f03cb (patch)
tree34d59d4b04392c72a73bae02d35681abcf2a4901
parenta9d0472758f4fb43edc0ea6602f59ef7f8075ec5 (diff)
downloadscummvm-rg350-858c6c4d5bb40a29550009b07f8d4b583d3f03cb.tar.gz
scummvm-rg350-858c6c4d5bb40a29550009b07f8d4b583d3f03cb.tar.bz2
scummvm-rg350-858c6c4d5bb40a29550009b07f8d4b583d3f03cb.zip
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
-rw-r--r--graphics/font.cpp26
-rw-r--r--graphics/font.h8
-rw-r--r--graphics/fontman.cpp5
-rw-r--r--graphics/fontman.h3
-rw-r--r--graphics/module.mk1
-rw-r--r--graphics/scummfont.cpp18
-rw-r--r--gui/about.cpp2
-rw-r--r--gui/newgui.cpp23
-rw-r--r--gui/newgui.h11
-rw-r--r--gui/widget.cpp5
10 files changed, 47 insertions, 55 deletions
diff --git a/graphics/font.cpp b/graphics/font.cpp
index aac9813bca..f5a6135dff 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -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;
}
}
diff --git a/graphics/font.h b/graphics/font.h
index 4bacda5dde..134ba8bb48 100644
--- a/graphics/font.h
+++ b/graphics/font.h
@@ -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
diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp
index 5ba5a80c0a..0bee9ea925 100644
--- a/graphics/fontman.cpp
+++ b/graphics/fontman.cpp
@@ -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;
}
diff --git a/graphics/fontman.h b/graphics/fontman.h
index 77d953b9e8..dff104f4c6 100644
--- a/graphics/fontman.h
+++ b/graphics/fontman.h
@@ -35,7 +35,8 @@ public:
enum FontUsage {
kOSDFont,
kConsoleFont,
- kGUIFont
+ kGUIFont,
+ kBigGUIFont
};
/**
diff --git a/graphics/module.mk b/graphics/module.mk
index fc608f12c5..0488ead3a6 100644
--- a/graphics/module.mk
+++ b/graphics/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
graphics/font.o \
graphics/fontman.o \
graphics/newfont.o \
+ graphics/newfont_big.o \
graphics/surface.o
MODULE_DIRS += \
diff --git a/graphics/scummfont.cpp b/graphics/scummfont.cpp
index 7ec03edcb2..32935be6f8 100644
--- a/graphics/scummfont.cpp
+++ b/graphics/scummfont.cpp
@@ -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);
diff --git a/gui/about.cpp b/gui/about.cpp
index 1fbaaaeb3e..e2bb3ac3fd 100644
--- a/gui/about.cpp
+++ b/gui/about.cpp
@@ -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("");
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 99f43c18a8..98014faf24 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -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);
}
//
diff --git a/gui/newgui.h b/gui/newgui.h
index f8ee91a78e..ed4f69dd96 100644
--- a/gui/newgui.h
+++ b/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);
diff --git a/gui/widget.cpp b/gui/widget.cpp
index e36be7b23a..865b011a77 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -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);