[Scummvm-cvs-logs] SF.net SVN: scummvm: [30809] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Wed Feb 6 15:13:00 CET 2008
Revision: 30809
http://scummvm.svn.sourceforge.net/scummvm/?rev=30809&view=rev
Author: peres001
Date: 2008-02-06 06:12:59 -0800 (Wed, 06 Feb 2008)
Log Message:
-----------
Made font handling stateless.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/graphics.cpp
scummvm/trunk/engines/parallaction/graphics.h
Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp 2008-02-06 14:05:08 UTC (rev 30808)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2008-02-06 14:12:59 UTC (rev 30809)
@@ -611,8 +611,7 @@
setupLabelSurface(*cnv, w, h);
- setFont(font);
- drawText(cnv, 0, 0, text, 0);
+ drawText(font, cnv, 0, 0, text, 0);
}
return label;
@@ -626,23 +625,21 @@
uint w, h;
- setFont(font);
-
if (_vm->getPlatform() == Common::kPlatformAmiga) {
w = font->getStringWidth(text) + 2;
h = font->height() + 2;
setupLabelSurface(*cnv, w, h);
- drawText(cnv, 0, 2, text, 0);
- drawText(cnv, 2, 0, text, color);
+ drawText(font, cnv, 0, 2, text, 0);
+ drawText(font, cnv, 2, 0, text, color);
} else {
w = font->getStringWidth(text);
h = font->height();
setupLabelSurface(*cnv, w, h);
- drawText(cnv, 0, 0, text, color);
+ drawText(font, cnv, 0, 0, text, color);
}
uint id = _numLabels;
@@ -762,13 +759,13 @@
}
-void Gfx::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height) {
+void Gfx::getStringExtent(Font *font, char *text, uint16 maxwidth, int16* width, int16* height) {
uint16 lines = 0;
uint16 w = 0;
*width = 0;
- uint16 blankWidth = _font->getStringWidth(" ");
+ uint16 blankWidth = font->getStringWidth(" ");
uint16 tokenWidth = 0;
char token[MAX_TOKEN_LEN];
@@ -776,7 +773,7 @@
while (strlen(text) != 0) {
text = parseNextToken(text, token, MAX_TOKEN_LEN, " ", true);
- tokenWidth = _font->getStringWidth(token);
+ tokenWidth = font->getStringWidth(token);
w += tokenWidth;
@@ -806,13 +803,6 @@
}
-void Gfx::setFont(Font *font) {
- assert(font);
- _font = font;
-}
-
-
-
void Gfx::copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surface &dst) {
byte *s = (byte*)src.getBasePtr(r.left, r.top);
@@ -854,8 +844,6 @@
_halfbrite = false;
_hbCircleRadius = 0;
- _font = NULL;
-
registerVar("background_mode", 1);
_varBackgroundMode = 1;
@@ -934,13 +922,12 @@
int16 w, h;
- setFont(_vm->_dialogueFont);
- getStringExtent(text, MAX_BALLOON_WIDTH, &w, &h);
+ getStringExtent(_vm->_dialogueFont, text, MAX_BALLOON_WIDTH, &w, &h);
int id = createBalloon(w+5, h, winding, 1);
Gfx::Balloon *balloon = &_balloons[id];
- drawWrappedText(&balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
+ drawWrappedText(_vm->_dialogueFont, &balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
balloon->x = x;
balloon->y = y;
@@ -952,13 +939,12 @@
int16 w, h;
- setFont(_vm->_dialogueFont);
- getStringExtent(text, MAX_BALLOON_WIDTH, &w, &h);
+ getStringExtent(_vm->_dialogueFont, text, MAX_BALLOON_WIDTH, &w, &h);
int id = createBalloon(w+5, h, winding, 1);
Gfx::Balloon *balloon = &_balloons[id];
- drawWrappedText(&balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
+ drawWrappedText(_vm->_dialogueFont, &balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
balloon->x = _dialogueBalloonX[id];
balloon->y = 10;
@@ -974,7 +960,7 @@
void Gfx::setBalloonText(uint id, char *text, byte textColor) {
Gfx::Balloon *balloon = getBalloon(id);
balloon->surface.fillRect(balloon->innerBox, 1);
- drawWrappedText(&balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
+ drawWrappedText(_vm->_dialogueFont, &balloon->surface, text, textColor, MAX_BALLOON_WIDTH);
}
@@ -982,12 +968,11 @@
int16 w, h;
- setFont(_vm->_dialogueFont);
- getStringExtent(text, MAX_BALLOON_WIDTH, &w, &h);
+ getStringExtent(_vm->_dialogueFont, text, MAX_BALLOON_WIDTH, &w, &h);
int id = createBalloon(w+(endGame ? 5 : 10), h+5, -1, BALLOON_TRANSPARENT_COLOR);
Gfx::Balloon *balloon = &_balloons[id];
- drawWrappedText(&balloon->surface, text, 0, MAX_BALLOON_WIDTH);
+ drawWrappedText(_vm->_dialogueFont, &balloon->surface, text, 0, MAX_BALLOON_WIDTH);
balloon->x = 5;
balloon->y = 5;
@@ -1027,13 +1012,13 @@
freeBalloons();
}
-void Gfx::drawText(Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color) {
+void Gfx::drawText(Font *font, Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color) {
byte *dst = (byte*)surf->getBasePtr(x, y);
- _font->setColor(color);
- _font->drawString(dst, surf->w, text);
+ font->setColor(color);
+ font->drawString(dst, surf->w, text);
}
-void Gfx::drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 wrapwidth) {
+void Gfx::drawWrappedText(Font *font, Graphics::Surface* surf, char *text, byte color, int16 wrapwidth) {
uint16 lines = 0;
uint16 linewidth = 0;
@@ -1041,7 +1026,7 @@
uint16 rx = 10;
uint16 ry = 4;
- uint16 blankWidth = _font->getStringWidth(" ");
+ uint16 blankWidth = font->getStringWidth(" ");
uint16 tokenWidth = 0;
char token[MAX_TOKEN_LEN];
@@ -1060,9 +1045,9 @@
strcpy(token, "> .......");
strncpy(token+2, _password, strlen(_password));
- tokenWidth = _font->getStringWidth(token);
+ tokenWidth = font->getStringWidth(token);
} else {
- tokenWidth = _font->getStringWidth(token);
+ tokenWidth = font->getStringWidth(token);
linewidth += tokenWidth;
@@ -1080,7 +1065,7 @@
}
- drawText(surf, rx, ry, token, color);
+ drawText(font, surf, rx, ry, token, color);
rx += tokenWidth + blankWidth;
linewidth += blankWidth;
Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h 2008-02-06 14:05:08 UTC (rev 30808)
+++ scummvm/trunk/engines/parallaction/graphics.h 2008-02-06 14:12:59 UTC (rev 30809)
@@ -481,7 +481,7 @@
int setSingleBalloon(char *text, uint16 x, uint16 y, uint16 winding, byte textColor);
void setBalloonText(uint id, char *text, byte textColor);
int hitTestDialogueBalloon(int x, int y);
- void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);
+ void getStringExtent(Font *font, char *text, uint16 maxwidth, int16* width, int16* height);
// other items
int setItem(Frames* frames, uint16 x, uint16 y, byte transparentColor = 0);
@@ -529,7 +529,6 @@
protected:
Parallaction* _vm;
- Font *_font;
bool _halfbrite;
Common::Point _hbCirclePos;
@@ -583,9 +582,8 @@
Balloon *getBalloon(uint id);
// low level text and patches
- void setFont(Font* font);
- void drawText(Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color);
- void drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 wrapwidth);
+ void drawText(Font *font, Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color);
+ void drawWrappedText(Font *font, Graphics::Surface* surf, char *text, byte color, int16 wrapwidth);
void blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor);
void unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list