aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2007-08-11 17:25:57 +0000
committerNicola Mettifogo2007-08-11 17:25:57 +0000
commitb07f787f7ff49c0a88122cd60b6c73ae850adc26 (patch)
tree15b4120a5d1c7a1d828e9bc3333d4d411caf88a5 /engines/parallaction
parent81b864e9e8199b0102b122626badba059eb618d4 (diff)
downloadscummvm-rg350-b07f787f7ff49c0a88122cd60b6c73ae850adc26.tar.gz
scummvm-rg350-b07f787f7ff49c0a88122cd60b6c73ae850adc26.tar.bz2
scummvm-rg350-b07f787f7ff49c0a88122cd60b6c73ae850adc26.zip
Moved core font management from Gfx to engine. Gfx still retains features related to displaying text on screen.
svn-id: r28530
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/animation.cpp2
-rw-r--r--engines/parallaction/callables_ns.cpp10
-rw-r--r--engines/parallaction/dialogue.cpp2
-rw-r--r--engines/parallaction/font.cpp30
-rw-r--r--engines/parallaction/graphics.cpp47
-rw-r--r--engines/parallaction/graphics.h11
-rw-r--r--engines/parallaction/location.cpp27
-rw-r--r--engines/parallaction/menu.cpp4
-rw-r--r--engines/parallaction/parallaction.h18
-rw-r--r--engines/parallaction/parallaction_br.cpp24
-rw-r--r--engines/parallaction/parallaction_ns.cpp34
-rw-r--r--engines/parallaction/zone.cpp6
12 files changed, 125 insertions, 90 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp
index 314cf2a18e..51a21141da 100644
--- a/engines/parallaction/animation.cpp
+++ b/engines/parallaction/animation.cpp
@@ -102,7 +102,7 @@ Animation *Parallaction::parseAnimation(Script& script, AnimationList &list, cha
}
}
if (!scumm_stricmp(_tokens[0], "label")) {
- _gfx->makeCnvFromString(&vD0->_label._cnv, _tokens[1]);
+ renderLabel(&vD0->_label._cnv, _tokens[1]);
}
if (!scumm_stricmp(_tokens[0], "flags")) {
uint16 _si = 1;
diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp
index 26b472345e..89d59b948b 100644
--- a/engines/parallaction/callables_ns.cpp
+++ b/engines/parallaction/callables_ns.cpp
@@ -336,7 +336,7 @@ void Parallaction_ns::_c_setMask(void *parm) {
void Parallaction_ns::_c_endComment(void *param) {
- _gfx->showLocationComment(_location._endComment, true);
+ showLocationComment(_location._endComment, true);
Palette pal(_gfx->_palette);
pal.makeGrayscale();
@@ -413,7 +413,7 @@ void Parallaction_ns::_c_finito(void *parm) {
_gfx->setPalette(_gfx->_palette);
if (gameCompleted) {
- _gfx->setFont(kFontMenu);
+ _gfx->setFont(_menuFont);
_gfx->displayCenteredString(70, v4C[_language]);
_gfx->displayCenteredString(100, v3C[_language]);
_gfx->displayCenteredString(130, v2C[_language]);
@@ -426,7 +426,7 @@ void Parallaction_ns::_c_finito(void *parm) {
_engineFlags |= kEngineChangeLocation;
} else {
- _gfx->setFont(kFontMenu);
+ _gfx->setFont(_menuFont);
_gfx->displayCenteredString(70, v8C[_language]);
_gfx->displayCenteredString(100, v7C[_language]);
_gfx->displayCenteredString(130, v6C[_language]);
@@ -471,7 +471,7 @@ void Parallaction_ns::_c_testResult(void *parm) {
_disk->selectArchive("disk1");
parseLocation("common");
- _gfx->setFont(kFontMenu);
+ _gfx->setFont(_menuFont);
_gfx->displayCenteredString(38, _slideText[0]);
_gfx->displayCenteredString(58, _slideText[1]);
@@ -516,7 +516,7 @@ void Parallaction_ns::_c_startIntro(void *parm) {
void Parallaction_ns::_c_endIntro(void *parm) {
- _gfx->setFont(kFontMenu);
+ _gfx->setFont(_menuFont);
debugC(1, kDebugLocation, "endIntro()");
diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp
index 61d9ed2086..9e0416f493 100644
--- a/engines/parallaction/dialogue.cpp
+++ b/engines/parallaction/dialogue.cpp
@@ -493,7 +493,7 @@ int16 DialogueManager::getHoverAnswer(int16 x, int16 y) {
void Parallaction::runDialogue(SpeakData *data) {
debugC(1, kDebugDialogue, "runDialogue: starting dialogue '%s'", data->_name);
- _gfx->setFont(kFontDialogue);
+ _gfx->setFont(_dialogueFont);
if (getPlatform() == Common::kPlatformPC)
showCursor(false);
diff --git a/engines/parallaction/font.cpp b/engines/parallaction/font.cpp
index 99ec28ec60..d0973c27e7 100644
--- a/engines/parallaction/font.cpp
+++ b/engines/parallaction/font.cpp
@@ -575,25 +575,17 @@ Font *DosDisk_br::createFont(const char *name, Common::ReadStream &stream) {
return new BraFont(stream);
}
-
-void Gfx::initFonts() {
-
- if (_vm->getGameType() == GType_Nippon) {
- if (_vm->getPlatform() == Common::kPlatformPC) {
- _fonts[kFontDialogue] = _vm->_disk->loadFont("comic");
- _fonts[kFontLabel] = _vm->_disk->loadFont("topaz");
- _fonts[kFontMenu] = _vm->_disk->loadFont("slide");
- } else {
- _fonts[kFontDialogue] = _vm->_disk->loadFont("comic");
-
- Common::MemoryReadStream stream(_amigaTopazFont, 2600, false);
- _fonts[kFontLabel] = new AmigaFont(stream);
-
- _fonts[kFontMenu] = _vm->_disk->loadFont("slide");
- }
- } else
- if (_vm->getGameType() == GType_BRA) {
- _fonts[kFontMenu] = _vm->_disk->loadFont("russia");
+void Parallaction_ns::initFonts() {
+
+ if (getPlatform() == Common::kPlatformPC) {
+ _dialogueFont = _disk->loadFont("comic");
+ _labelFont = _disk->loadFont("topaz");
+ _menuFont = _disk->loadFont("slide");
+ } else {
+ _dialogueFont = _disk->loadFont("comic");
+ Common::MemoryReadStream stream(_amigaTopazFont, 2600, false);
+ _labelFont = new AmigaFont(stream);
+ _menuFont = _disk->loadFont("slide");
}
}
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 536ac76583..cdc2641666 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -220,25 +220,7 @@ void Gfx::drawBalloon(const Common::Rect& r, uint16 winding) {
return;
}
-void Gfx::showLocationComment(const char *text, bool end) {
- setFont(kFontDialogue);
-
- int16 w, h;
- getStringExtent(const_cast<char*>(text), 130, &w, &h);
-
- Common::Rect r(w + (end ? 5 : 10), h + 5);
- r.moveTo(5, 5);
-
- floodFill(kBitFront, r, 0);
- r.grow(-2);
- floodFill(kBitFront, r, 1);
- displayWrappedString(const_cast<char*>(text), 3, 5, 0, 130);
-
- updateScreen();
-
- return;
-}
void Gfx::setPalette(Palette pal) {
@@ -618,25 +600,7 @@ void Gfx::restoreGetBackground(const Common::Rect& r, byte *data) {
return;
}
-void Gfx::makeCnvFromString(Graphics::Surface *cnv, char *text) {
- assert(_font == _fonts[kFontLabel]);
-
- if (_vm->getPlatform() == Common::kPlatformAmiga) {
- cnv->create(_font->getStringWidth(text) + 16, 10, 1);
- _font->setColor(7);
- _font->drawString((byte*)cnv->pixels + 1, cnv->w, text);
- _font->drawString((byte*)cnv->pixels + 1 + cnv->w * 2, cnv->w, text);
- _font->drawString((byte*)cnv->pixels + cnv->w, cnv->w, text);
- _font->drawString((byte*)cnv->pixels + 2 + cnv->w, cnv->w, text);
- _font->setColor(1);
- _font->drawString((byte*)cnv->pixels + 1 + cnv->w, cnv->w, text);
- } else {
- cnv->create(_font->getStringWidth(text), _font->height(), 1);
- _font->drawString((byte*)cnv->pixels, cnv->w, text);
- }
-
-}
void Gfx::displayString(uint16 x, uint16 y, const char *text, byte color) {
byte *dst = (byte*)_buffers[kBitFront]->getBasePtr(x, y);
@@ -733,9 +697,9 @@ void Gfx::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* heig
}
-void Gfx::setFont(Fonts name) {
- assert(name < 3);
- _font = _fonts[name];
+void Gfx::setFont(Font *font) {
+ assert(font);
+ _font = font;
}
@@ -861,7 +825,6 @@ Gfx::Gfx(Parallaction* vm) :
memset(_palettefx, 0, sizeof(_palettefx));
initMouse( 0 );
- initFonts();
_halfbrite = false;
@@ -877,10 +840,6 @@ Gfx::~Gfx() {
_buffers[kBitBack]->free();
delete _buffers[kBitBack];
- delete _fonts[kFontDialogue];
- delete _fonts[kFontLabel];
- delete _fonts[kFontMenu];
-
_mouseComposedArrow->free();
delete _mouseComposedArrow;
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index c462a3d72e..2134a17e4e 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -115,11 +115,6 @@ class Parallaction;
struct DoorData;
struct GetData;
-enum Fonts {
- kFontDialogue = 0,
- kFontLabel = 1,
- kFontMenu = 2
-};
struct MaskBuffer {
// handles a 2-bit depth buffer used for z-buffering
@@ -196,14 +191,12 @@ public:
public:
// balloons and text
- void showLocationComment(const char *text, bool end = false);
void drawBalloon(const Common::Rect& r, uint16 arg_8);
void displayString(uint16 x, uint16 y, const char *text, byte color);
void displayCenteredString(uint16 y, const char *text);
bool displayWrappedString(char *text, uint16 x, uint16 y, byte color, int16 wrapwidth = -1);
uint16 getStringWidth(const char *text);
void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);
- void makeCnvFromString(Graphics::Surface *cnv, char *text);
// cut/paste
void flatBlitCnv(Graphics::Surface *cnv, int16 x, int16 y, Gfx::Buffers buffer);
@@ -238,7 +231,7 @@ public:
// misc
int16 queryMask(int16 v);
void setMousePointer(int16 index);
- void setFont(Fonts name);
+ void setFont(Font* font);
void swapBuffers();
void updateScreen();
void setBackground(Graphics::Surface *surf);
@@ -262,7 +255,6 @@ protected:
static byte _mouseArrow[256];
Graphics::Surface *_mouseComposedArrow;
Font *_font;
- Font *_fonts[3];
bool _halfbrite;
protected:
@@ -271,7 +263,6 @@ protected:
void blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer);
void initMouse(uint16 arg_0);
void screenClip(Common::Rect& r, Common::Point& p);
- void initFonts();
};
diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp
index d844fa8d30..a1545b9eb7 100644
--- a/engines/parallaction/location.cpp
+++ b/engines/parallaction/location.cpp
@@ -37,7 +37,7 @@ void Parallaction::parseLocation(const char *filename) {
debugC(1, kDebugLocation, "parseLocation('%s')", filename);
uint16 _si = 1;
- _gfx->setFont(kFontLabel);
+ _gfx->setFont(_labelFont);
Script *_locationScript = _disk->loadLocation(filename);
_hasLocationSound = false;
@@ -266,6 +266,27 @@ void Parallaction::setBackground(const char *background, const char *mask, const
return;
}
+
+void Parallaction::showLocationComment(const char *text, bool end) {
+
+ _gfx->setFont(_dialogueFont);
+
+ int16 w, h;
+ _gfx->getStringExtent(const_cast<char*>(text), 130, &w, &h);
+
+ Common::Rect r(w + (end ? 5 : 10), h + 5);
+ r.moveTo(5, 5);
+
+ _gfx->floodFill(Gfx::kBitFront, r, 0);
+ r.grow(-2);
+ _gfx->floodFill(Gfx::kBitFront, r, 1);
+ _gfx->displayWrappedString(const_cast<char*>(text), 3, 5, 0, 130);
+
+ _gfx->updateScreen();
+
+ return;
+}
+
void Parallaction::switchBackground(const char* background, const char* mask) {
// printf("switchBackground(%s)", name);
@@ -372,7 +393,7 @@ void Parallaction::changeLocation(char *location) {
if (list.size() > 1) {
if (list[1] == "slide") {
showSlide(list[0].c_str());
- _gfx->setFont(kFontMenu);
+ _gfx->setFont(_menuFont);
_gfx->displayCenteredString(14, _slideText[0]); // displays text on screen
_gfx->updateScreen();
waitUntilLeftClick();
@@ -466,7 +487,7 @@ void Parallaction::doLocationEnterTransition() {
_gfx->swapBuffers();
_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
- _gfx->showLocationComment(_location._comment);
+ showLocationComment(_location._comment, false);
waitUntilLeftClick();
_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront );
diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp
index 9718843bfc..14d50c6373 100644
--- a/engines/parallaction/menu.cpp
+++ b/engines/parallaction/menu.cpp
@@ -114,7 +114,7 @@ void Menu::start() {
splash();
- _vm->_gfx->setFont(kFontMenu);
+ _vm->_gfx->setFont(_vm->_menuFont);
_language = chooseLanguage();
_vm->_disk->setLanguage(_language);
@@ -340,7 +340,7 @@ void Menu::selectCharacter() {
_vm->changeCursor(kCursorArrow);
_vm->_soundMan->stopMusic();
- _vm->_gfx->setFont(kFontMenu);
+ _vm->_gfx->setFont(_vm->_menuFont);
_vm->_disk->selectArchive((_vm->getFeatures() & GF_LANG_MULT) ? "disk1" : "disk0");
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 21cfb3984f..0de3ec19e7 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -357,6 +357,7 @@ public:
+
public:
int getGameType() const;
uint32 getFeatures() const;
@@ -395,6 +396,10 @@ public:
ZoneList _zones;
AnimationList _animations;
+ Font *_labelFont;
+ Font *_menuFont;
+ Font *_dialogueFont;
+
protected: // data
Debugger *_debugger;
@@ -457,6 +462,7 @@ protected: // members
void resolveLocationForwards();
void switchBackground(const char* background, const char* mask);
void freeLocation();
+ void showLocationComment(const char *text, bool end);
void parseZone(Script &script, ZoneList &list, char *name);
void parseZoneTypeBlock(Script &script, Zone *z);
@@ -483,6 +489,7 @@ protected: // members
public:
virtual void callFunction(uint index, void* parm) { }
+ virtual void renderLabel(Graphics::Surface *cnv, char *text) { }
public:
const char **_zoneFlagNamesRes;
@@ -497,7 +504,7 @@ class Parallaction_ns : public Parallaction {
public:
Parallaction_ns(OSystem* syst) : Parallaction(syst) { }
- ~Parallaction_ns() { }
+ ~Parallaction_ns();
int init();
@@ -505,6 +512,11 @@ public:
typedef void (Parallaction_ns::*Callable)(void*);
virtual void callFunction(uint index, void* parm);
+ void renderLabel(Graphics::Surface *cnv, char *text);
+
+private:
+ void initFonts();
+ void freeFonts();
private:
void initResources();
@@ -552,7 +564,7 @@ class Parallaction_br : public Parallaction {
public:
Parallaction_br(OSystem* syst) : Parallaction(syst) { }
- ~Parallaction_br() { }
+ ~Parallaction_br();
int init();
int go();
@@ -568,6 +580,8 @@ public:
private:
void initResources();
void initGame();
+ void initFonts();
+ void freeFonts();
void splash(const char *name);
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 0455b50381..a53ab54bf6 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -53,12 +53,17 @@ int Parallaction_br::init() {
_soundMan = new DummySoundMan(this);
initResources();
+ initFonts();
Parallaction::init();
return 0;
}
+Parallaction_br::~Parallaction_br() {
+ freeFonts();
+}
+
void Parallaction_br::callFunction(uint index, void* parm) {
assert(index < 6); // magic value 6 is maximum # of callables for Big Red Adventure
@@ -106,4 +111,23 @@ void Parallaction_br::initGame() {
return;
}
+
+
+void Parallaction_br::initFonts() {
+
+ // TODO: find out which font is used for labels
+
+ _menuFont = _disk->loadFont("russia");
+ _dialogueFont = _disk->loadFont("comic");
+
+}
+
+void Parallaction_br::freeFonts() {
+
+ delete _menuFont;
+ delete _dialogueFont;
+
+ return;
+}
+
} // namespace Parallaction
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index 947cb22a7f..0b088442e4 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -62,12 +62,46 @@ int Parallaction_ns::init() {
}
initResources();
+ initFonts();
Parallaction::init();
return 0;
}
+Parallaction_ns::~Parallaction_ns() {
+ freeFonts();
+}
+
+
+void Parallaction_ns::freeFonts() {
+
+ delete _dialogueFont;
+ delete _labelFont;
+ delete _menuFont;
+
+ return;
+}
+
+void Parallaction_ns::renderLabel(Graphics::Surface *cnv, char *text) {
+
+ if (_vm->getPlatform() == Common::kPlatformAmiga) {
+ cnv->create(_labelFont->getStringWidth(text) + 16, 10, 1);
+
+ _labelFont->setColor(7);
+ _labelFont->drawString((byte*)cnv->pixels + 1, cnv->w, text);
+ _labelFont->drawString((byte*)cnv->pixels + 1 + cnv->w * 2, cnv->w, text);
+ _labelFont->drawString((byte*)cnv->pixels + cnv->w, cnv->w, text);
+ _labelFont->drawString((byte*)cnv->pixels + 2 + cnv->w, cnv->w, text);
+ _labelFont->setColor(1);
+ _labelFont->drawString((byte*)cnv->pixels + 1 + cnv->w, cnv->w, text);
+ } else {
+ cnv->create(_labelFont->getStringWidth(text), _labelFont->height(), 1);
+ _labelFont->drawString((byte*)cnv->pixels, cnv->w, text);
+ }
+
+}
+
void Parallaction_ns::callFunction(uint index, void* parm) {
assert(index < 25); // magic value 25 is maximum # of callables for Nippon Safes
diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp
index ed033e79ed..be55509100 100644
--- a/engines/parallaction/zone.cpp
+++ b/engines/parallaction/zone.cpp
@@ -92,7 +92,7 @@ void Parallaction::parseZone(Script &script, ZoneList &list, char *name) {
}
if (!scumm_stricmp(_tokens[0], "label")) {
// printf("label: %s", _tokens[1]);
- _gfx->makeCnvFromString(&z->_label._cnv, _tokens[1]);
+ renderLabel(&z->_label._cnv, _tokens[1]);
}
if (!scumm_stricmp(_tokens[0], "flags")) {
uint16 _si = 1;
@@ -302,7 +302,7 @@ void Parallaction::displayCharacterComment(ExamineData *data) {
// BUG item #1762614.
_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
- _gfx->setFont(kFontDialogue);
+ _gfx->setFont(_dialogueFont);
_gfx->flatBlitCnv(_char._talk, 0, 190, 80, Gfx::kBitFront);
int16 v26, v28;
@@ -343,7 +343,7 @@ void Parallaction::displayItemComment(ExamineData *data) {
int16 v6A = 0, v6C = 0;
- _gfx->setFont(kFontDialogue);
+ _gfx->setFont(_dialogueFont);
_gfx->getStringExtent(data->_description, 130, &v6C, &v6A);
Common::Rect r(v6C, v6A);
r.moveTo(0, 90);