[Scummvm-cvs-logs] SF.net SVN: scummvm: [30362] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Wed Jan 9 23:03:53 CET 2008
Revision: 30362
http://scummvm.svn.sourceforge.net/scummvm/?rev=30362&view=rev
Author: peres001
Date: 2008-01-09 14:03:51 -0800 (Wed, 09 Jan 2008)
Log Message:
-----------
Refactored some text drawing code.
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-01-09 21:54:58 UTC (rev 30361)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2008-01-09 22:03:51 UTC (rev 30362)
@@ -507,6 +507,11 @@
#define LABEL_TRANSPARENT_COLOR 0xFF
+void setupLabelSurface(Graphics::Surface &surf, uint w, uint h) {
+ surf.create(w, h, 1);
+ surf.fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
+}
+
Label *Gfx::renderFloatingLabel(Font *font, char *text) {
Label *label = new Label;
@@ -518,8 +523,7 @@
w = font->getStringWidth(text) + 16;
h = 10;
- cnv->create(w, h, 1);
- cnv->fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
+ setupLabelSurface(*cnv, w, h);
font->setColor(7);
font->drawString((byte*)cnv->pixels + 1, cnv->w, text);
@@ -532,10 +536,10 @@
w = font->getStringWidth(text);
h = font->height();
- cnv->create(w, h, 1);
- cnv->fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
+ setupLabelSurface(*cnv, w, h);
- font->drawString((byte*)cnv->pixels, cnv->w, text);
+ setFont(font);
+ drawText(cnv, 0, 0, text, 0);
}
return label;
@@ -549,26 +553,23 @@
uint w, h;
+ setFont(font);
+
if (_vm->getPlatform() == Common::kPlatformAmiga) {
w = font->getStringWidth(text) + 2;
h = font->height() + 2;
- cnv->create(w, h, 1);
- cnv->fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
+ setupLabelSurface(*cnv, w, h);
- font->setColor(0);
- font->drawString((byte*)cnv->getBasePtr(0, 2), cnv->pitch, text);
- font->setColor(color);
- font->drawString((byte*)cnv->getBasePtr(2, 0), cnv->pitch, text);
+ drawText(cnv, 0, 2, text, 0);
+ drawText(cnv, 2, 0, text, color);
} else {
w = font->getStringWidth(text);
h = font->height();
- cnv->create(w, h, 1);
- cnv->fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
+ setupLabelSurface(*cnv, w, h);
- font->setColor(color);
- font->drawString((byte*)cnv->getBasePtr(0, 0), cnv->pitch, text);
+ drawText(cnv, 0, 0, text, color);
}
uint id = _numLabels;
Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h 2008-01-09 21:54:58 UTC (rev 30361)
+++ scummvm/trunk/engines/parallaction/graphics.h 2008-01-09 22:03:51 UTC (rev 30362)
@@ -266,10 +266,8 @@
void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);
// labels
- Label *_floatingLabel;
void setFloatingLabel(Label *label);
Label *renderFloatingLabel(Font *font, char *text);
-
uint createLabel(Font *font, const char *text, byte color);
void showLabel(uint id, int16 x, int16 y);
void hideLabel(uint id);
@@ -376,6 +374,7 @@
#define MAX_NUM_LABELS 5
Label* _labels[MAX_NUM_LABELS];
uint _numLabels;
+ Label *_floatingLabel;
void drawInventory();
void updateFloatingLabel();
@@ -383,7 +382,6 @@
void drawItems();
void drawBalloons();
-
void initBuffers(int w, int h);
void freeBuffers();
@@ -392,12 +390,13 @@
int createBalloon(int16 w, int16 h, int16 winding, uint16 borderThickness);
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);
bool drawWrappedText(Graphics::Surface* surf, char *text, byte color, int16 wrapwidth);
+
void blit(const Common::Rect& r, uint16 z, byte *data, Graphics::Surface *surf);
void flatBlit(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor);
- void setFont(Font* font);
-
};
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