aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/parallaction/graphics.cpp31
-rw-r--r--engines/parallaction/graphics.h9
2 files changed, 20 insertions, 20 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 296218df15..595c264c59 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -507,6 +507,11 @@ void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Graphics::Surface *s
#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 @@ Label *Gfx::renderFloatingLabel(Font *font, char *text) {
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 @@ Label *Gfx::renderFloatingLabel(Font *font, char *text) {
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 Gfx::createLabel(Font *font, const char *text, byte color) {
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;
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 654b76fde9..a9af5e85ab 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -266,10 +266,8 @@ public:
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 @@ protected:
#define MAX_NUM_LABELS 5
Label* _labels[MAX_NUM_LABELS];
uint _numLabels;
+ Label *_floatingLabel;
void drawInventory();
void updateFloatingLabel();
@@ -383,7 +382,6 @@ protected:
void drawItems();
void drawBalloons();
-
void initBuffers(int w, int h);
void freeBuffers();
@@ -392,12 +390,13 @@ protected:
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);
-
};