aboutsummaryrefslogtreecommitdiff
path: root/engines/teenagent
diff options
context:
space:
mode:
authorD G Turner2012-09-24 01:22:08 +0100
committerD G Turner2012-09-24 01:22:08 +0100
commit86475a0b0687e4a90f8d9601f5ed7a40177b8491 (patch)
treeeea7b44e0285600592909a34d800b7eaf79911c9 /engines/teenagent
parent09033519749479cea6f84add9eea4b09a99b0e8a (diff)
downloadscummvm-rg350-86475a0b0687e4a90f8d9601f5ed7a40177b8491.tar.gz
scummvm-rg350-86475a0b0687e4a90f8d9601f5ed7a40177b8491.tar.bz2
scummvm-rg350-86475a0b0687e4a90f8d9601f5ed7a40177b8491.zip
TEENAGENT: Further cleanup for Font class.
Diffstat (limited to 'engines/teenagent')
-rw-r--r--engines/teenagent/font.cpp33
-rw-r--r--engines/teenagent/font.h11
-rw-r--r--engines/teenagent/resources.cpp7
-rw-r--r--engines/teenagent/scene.cpp4
4 files changed, 29 insertions, 26 deletions
diff --git a/engines/teenagent/font.cpp b/engines/teenagent/font.cpp
index 381f66237f..66feb9e406 100644
--- a/engines/teenagent/font.cpp
+++ b/engines/teenagent/font.cpp
@@ -32,24 +32,27 @@
namespace TeenAgent {
-Font::Font() : gridColor(0xd0), shadowColor(0), height(0), widthPack(0), data(0) {
+Font::Font() : _gridColor(0xd0), _shadowColor(0), _height(0), _widthPack(0), _data(0) {
}
Font::~Font() {
- delete[] data;
+ delete[] _data;
}
-void Font::load(const Pack &pack, int id) {
- delete[] data;
- data = NULL;
+void Font::load(const Pack &pack, int id, byte height, byte widthPack) {
+ delete[] _data;
+ _data = NULL;
Common::ScopedPtr<Common::SeekableReadStream> s(pack.getStream(id));
if (!s)
error("loading font %d failed", id);
- data = new byte[s->size()];
- s->read(data, s->size());
+ _data = new byte[s->size()];
+ s->read(_data, s->size());
debugC(0, kDebugFont, "font size: %d", s->size());
+
+ _height = height;
+ _widthPack = widthPack;
}
uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color) {
@@ -59,11 +62,11 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color)
return 0;
}
idx -= 0x20;
- byte *glyph = data + READ_LE_UINT16(data + idx * 2);
+ byte *glyph = _data + READ_LE_UINT16(_data + idx * 2);
int h = glyph[0], w = glyph[1];
if (surface == NULL || surface->pixels == NULL || y + h <= 0 || y >= screenHeight || x + w <= 0 || x >= screenWidth)
- return w - widthPack;
+ return w - _widthPack;
int i0 = 0, j0 = 0;
if (x < 0) {
@@ -86,7 +89,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color)
case 0:
break;
case 1:
- dst[j] = shadowColor;
+ dst[j] = _shadowColor;
break;
case 2:
dst[j] = color;
@@ -97,7 +100,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color)
}
dst += surface->pitch;
}
- return w - widthPack;
+ return w - _widthPack;
}
static uint findInStr(const Common::String &str, char c, uint pos = 0) {
@@ -109,7 +112,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String
if (surface != NULL) {
uint maxW = render(NULL, 0, 0, str, false);
if (showGrid)
- grid(surface, x - 4, y - 2, maxW + 8, 8 + 6, gridColor);
+ grid(surface, x - 4, y - 2, maxW + 8, 8 + 6, _gridColor);
uint i = 0, j;
do {
@@ -117,7 +120,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String
Common::String line(str.c_str() + i, j - i);
debugC(0, kDebugFont, "line: %s", line.c_str());
- if (y + (int)height >= 0) {
+ if (y + (int)_height >= 0) {
uint w = render(NULL, 0, 0, line, false);
int xp = x + (maxW - w) / 2;
for (uint k = 0; k < line.size(); ++k) {
@@ -126,7 +129,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String
} else if (y >= screenHeight)
break;
- y += height;
+ y += _height;
i = j + 1;
} while (i < str.size());
return maxW;
@@ -136,7 +139,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String
for (uint i = 0; i < str.size(); ++i) {
char c = str[i];
if (c == '\n') {
- y += height;
+ y += _height;
if (w > maxW)
maxW = w;
w = 0;
diff --git a/engines/teenagent/font.h b/engines/teenagent/font.h
index 72c5edc4f1..a61f145fa6 100644
--- a/engines/teenagent/font.h
+++ b/engines/teenagent/font.h
@@ -34,15 +34,18 @@ public:
Font();
~Font();
- void load(const Pack &pack, int id);
+ void load(const Pack &pack, int id, byte height, byte widthPack);
uint render(Graphics::Surface *surface, int x, int y, const Common::String &str, byte color, bool showGrid = false);
uint render(Graphics::Surface *surface, int x, int y, char c, byte color);
static void grid(Graphics::Surface *surface, int x, int y, int w, int h, byte color);
- byte gridColor, shadowColor;
- byte height, widthPack;
+ byte getHeight() { return _height; }
+ void setShadowColor(byte color) { _shadowColor = color; }
private:
- byte *data;
+ byte *_data;
+
+ byte _gridColor, _shadowColor;
+ byte _height, _widthPack;
};
} // End of namespace TeenAgent
diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp
index 4fd3edb2e3..442d0abf16 100644
--- a/engines/teenagent/resources.cpp
+++ b/engines/teenagent/resources.cpp
@@ -128,11 +128,8 @@ bool Resources::loadArchives(const ADGameDescription *gd) {
FilePack varia;
varia.open("varia.res");
- font7.load(varia, 7);
- font7.widthPack = 1;
- font7.height = 11;
- font8.load(varia, 8);
- font8.height = 31;
+ font7.load(varia, 7, 11, 1);
+ font8.load(varia, 8, 31, 0);
varia.close();
off.open("off.res");
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index f270792461..f2a8a8d012 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -633,7 +633,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) {
_vm->_system->fillScreen(0);
Graphics::Surface *surface = _vm->_system->lockScreen();
if (current_event.lan == 8) {
- _vm->res->font8.shadowColor = current_event.orientation;
+ _vm->res->font8.setShadowColor(current_event.orientation);
_vm->res->font8.render(surface, current_event.dst.x, current_event.dst.y, message, current_event.color);
} else {
_vm->res->font7.render(surface, current_event.dst.x, current_event.dst.y, message, textColorCredits);
@@ -1196,7 +1196,7 @@ Common::Point Scene::messagePosition(const Common::String &str, Common::Point me
++lines;
uint w = _vm->res->font7.render(NULL, 0, 0, str, 0);
- uint h = _vm->res->font7.height * lines + 3;
+ uint h = _vm->res->font7.getHeight() * lines + 3;
message_position.x -= w / 2;
message_position.y -= h;