aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD G Turner2012-09-23 18:53:22 +0100
committerD G Turner2012-09-23 18:53:22 +0100
commit09033519749479cea6f84add9eea4b09a99b0e8a (patch)
tree7c31bca75ea6ef4fc9546aab97d038fb62fcc484
parent82e9011d24f6f019a1803e982b3eac4cc4c142a3 (diff)
downloadscummvm-rg350-09033519749479cea6f84add9eea4b09a99b0e8a.tar.gz
scummvm-rg350-09033519749479cea6f84add9eea4b09a99b0e8a.tar.bz2
scummvm-rg350-09033519749479cea6f84add9eea4b09a99b0e8a.zip
TEENAGENT: Cleanup Font class.
This fixes a mismatched function prototype wrt. the definition and removes the underscores in various variables as per project coding standard. Also, minor reordering of functions for readability.
-rw-r--r--engines/teenagent/font.cpp46
-rw-r--r--engines/teenagent/font.h11
-rw-r--r--engines/teenagent/resources.cpp2
-rw-r--r--engines/teenagent/scene.cpp2
4 files changed, 31 insertions, 30 deletions
diff --git a/engines/teenagent/font.cpp b/engines/teenagent/font.cpp
index e75d05c3ed..381f66237f 100644
--- a/engines/teenagent/font.cpp
+++ b/engines/teenagent/font.cpp
@@ -32,7 +32,11 @@
namespace TeenAgent {
-Font::Font() : grid_color(0xd0), shadow_color(0), height(0), width_pack(0), data(0) {
+Font::Font() : gridColor(0xd0), shadowColor(0), height(0), widthPack(0), data(0) {
+}
+
+Font::~Font() {
+ delete[] data;
}
void Font::load(const Pack &pack, int id) {
@@ -59,7 +63,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color)
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 - width_pack;
+ return w - widthPack;
int i0 = 0, j0 = 0;
if (x < 0) {
@@ -82,7 +86,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color)
case 0:
break;
case 1:
- dst[j] = shadow_color;
+ dst[j] = shadowColor;
break;
case 2:
dst[j] = color;
@@ -93,29 +97,29 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color)
}
dst += surface->pitch;
}
- return w - width_pack;
+ return w - widthPack;
}
-static uint find_in_str(const Common::String &str, char c, uint pos = 0) {
+static uint findInStr(const Common::String &str, char c, uint pos = 0) {
while (pos < str.size() && str[pos] != c) ++pos;
return pos;
}
-uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String &str, byte color, bool show_grid) {
+uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String &str, byte color, bool showGrid) {
if (surface != NULL) {
- uint max_w = render(NULL, 0, 0, str, false);
- if (show_grid)
- grid(surface, x - 4, y - 2, max_w + 8, 8 + 6, grid_color);
+ uint maxW = render(NULL, 0, 0, str, false);
+ if (showGrid)
+ grid(surface, x - 4, y - 2, maxW + 8, 8 + 6, gridColor);
uint i = 0, j;
do {
- j = find_in_str(str, '\n', i);
+ j = findInStr(str, '\n', i);
Common::String line(str.c_str() + i, j - i);
debugC(0, kDebugFont, "line: %s", line.c_str());
if (y + (int)height >= 0) {
uint w = render(NULL, 0, 0, line, false);
- int xp = x + (max_w - w) / 2;
+ int xp = x + (maxW - w) / 2;
for (uint k = 0; k < line.size(); ++k) {
xp += render(surface, xp, y, line[k], color);
}
@@ -125,25 +129,25 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String
y += height;
i = j + 1;
} while (i < str.size());
- return max_w;
+ return maxW;
} else {
- //surface == NULL;
- uint w = 0, max_w = 0;
+ // surface == NULL;
+ uint w = 0, maxW = 0;
for (uint i = 0; i < str.size(); ++i) {
char c = str[i];
if (c == '\n') {
y += height;
- if (w > max_w)
- max_w = w;
+ if (w > maxW)
+ maxW = w;
w = 0;
continue;
}
w += render(NULL, 0, 0, c, color);
}
- if (w > max_w)
- max_w = w;
+ if (w > maxW)
+ maxW = w;
- return max_w;
+ return maxW;
}
}
@@ -158,8 +162,4 @@ void Font::grid(Graphics::Surface *surface, int x, int y, int w, int h, byte col
}
}
-Font::~Font() {
- delete[] data;
-}
-
} // End of namespace TeenAgent
diff --git a/engines/teenagent/font.h b/engines/teenagent/font.h
index 5146ace21f..72c5edc4f1 100644
--- a/engines/teenagent/font.h
+++ b/engines/teenagent/font.h
@@ -28,18 +28,19 @@
namespace TeenAgent {
class Pack;
+
class Font {
public:
- byte grid_color, shadow_color;
- byte height, width_pack;
-
Font();
+ ~Font();
+
void load(const Pack &pack, int id);
- uint render(Graphics::Surface *surface, int x, int y, const Common::String &str, byte color, bool grid = false);
+ 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);
- ~Font();
+ byte gridColor, shadowColor;
+ byte height, widthPack;
private:
byte *data;
};
diff --git a/engines/teenagent/resources.cpp b/engines/teenagent/resources.cpp
index 3a497f7a69..4fd3edb2e3 100644
--- a/engines/teenagent/resources.cpp
+++ b/engines/teenagent/resources.cpp
@@ -129,7 +129,7 @@ bool Resources::loadArchives(const ADGameDescription *gd) {
FilePack varia;
varia.open("varia.res");
font7.load(varia, 7);
- font7.width_pack = 1;
+ font7.widthPack = 1;
font7.height = 11;
font8.load(varia, 8);
font8.height = 31;
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index b94f013333..f270792461 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.shadow_color = current_event.orientation;
+ _vm->res->font8.shadowColor = 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);