[Scummvm-cvs-logs] SF.net SVN: scummvm: [28530] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sat Aug 11 19:25:58 CEST 2007


Revision: 28530
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28530&view=rev
Author:   peres001
Date:     2007-08-11 10:25:57 -0700 (Sat, 11 Aug 2007)

Log Message:
-----------
Moved core font management from Gfx to engine. Gfx still retains features related to displaying text on screen.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/animation.cpp
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/dialogue.cpp
    scummvm/trunk/engines/parallaction/font.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/location.cpp
    scummvm/trunk/engines/parallaction/menu.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/zone.cpp

Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/animation.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -102,7 +102,7 @@
 			}
 		}
 		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;

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -336,7 +336,7 @@
 
 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 @@
 	_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 @@
 
 		_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 @@
 	_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_endIntro(void *parm) {
 
-	_gfx->setFont(kFontMenu);
+	_gfx->setFont(_menuFont);
 
 	debugC(1, kDebugLocation, "endIntro()");
 

Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -493,7 +493,7 @@
 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);

Modified: scummvm/trunk/engines/parallaction/font.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/font.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/font.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -575,25 +575,17 @@
 	return new BraFont(stream);
 }
 
+void Parallaction_ns::initFonts() {
 
-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");
+	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");
 	}
 
 }

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -220,27 +220,9 @@
 	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) {
 	byte sysPal[256*4];
 
@@ -618,26 +600,8 @@
 	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);
 	_font->setColor(color);
@@ -733,9 +697,9 @@
 }
 
 
-void Gfx::setFont(Fonts name) {
-	assert(name < 3);
-	_font = _fonts[name];
+void Gfx::setFont(Font *font) {
+	assert(font);
+	_font = font;
 }
 
 
@@ -861,7 +825,6 @@
 	memset(_palettefx, 0, sizeof(_palettefx));
 
 	initMouse( 0 );
-	initFonts();
 
 	_halfbrite = false;
 
@@ -877,10 +840,6 @@
 	_buffers[kBitBack]->free();
 	delete _buffers[kBitBack];
 
-	delete _fonts[kFontDialogue];
-	delete _fonts[kFontLabel];
-	delete _fonts[kFontMenu];
-
 	_mouseComposedArrow->free();
 	delete _mouseComposedArrow;
 

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/graphics.h	2007-08-11 17:25:57 UTC (rev 28530)
@@ -115,11 +115,6 @@
 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:
 
 	// 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 @@
 	// 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 @@
 	static byte			_mouseArrow[256];
 	Graphics::Surface			*_mouseComposedArrow;
 	Font				*_font;
-	Font				*_fonts[3];
 	bool				_halfbrite;
 
 protected:
@@ -271,7 +263,6 @@
 	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();
 };
 
 

Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/location.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -37,7 +37,7 @@
     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 @@
 	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 @@
 	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 @@
 	_gfx->swapBuffers();
 	_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
 
-	_gfx->showLocationComment(_location._comment);
+	showLocationComment(_location._comment, false);
 	waitUntilLeftClick();
 
 	_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront );

Modified: scummvm/trunk/engines/parallaction/menu.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/menu.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/menu.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -114,7 +114,7 @@
 
 	splash();
 
-	_vm->_gfx->setFont(kFontMenu);
+	_vm->_gfx->setFont(_vm->_menuFont);
 
 	_language = chooseLanguage();
 	_vm->_disk->setLanguage(_language);
@@ -340,7 +340,7 @@
 	_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");
 

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-08-11 17:25:57 UTC (rev 28530)
@@ -357,6 +357,7 @@
 
 
 
+
 public:
 	int getGameType() const;
 	uint32 getFeatures() const;
@@ -395,6 +396,10 @@
 	ZoneList 		_zones;
 	AnimationList 	_animations;
 
+	Font		*_labelFont;
+	Font		*_menuFont;
+	Font		*_dialogueFont;
+
 protected:		// data
 
 	Debugger	*_debugger;
@@ -457,6 +462,7 @@
 	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 @@
 
 public:
 	virtual	void callFunction(uint index, void* parm) { }
+	virtual void renderLabel(Graphics::Surface *cnv, char *text) { }
 
 public:
 	const char **_zoneFlagNamesRes;
@@ -497,7 +504,7 @@
 
 public:
 	Parallaction_ns(OSystem* syst) : Parallaction(syst) { }
-	~Parallaction_ns() { }
+	~Parallaction_ns();
 
 	int init();
 
@@ -505,8 +512,13 @@
 	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();
 
 	static const Callable _dosCallables[25];
@@ -552,7 +564,7 @@
 
 public:
 	Parallaction_br(OSystem* syst) : Parallaction(syst) { }
-	~Parallaction_br() { }
+	~Parallaction_br();
 
 	int init();
 	int go();
@@ -568,6 +580,8 @@
 private:
 	void 		initResources();
 	void 		initGame();
+	void 		initFonts();
+	void 		freeFonts();
 
 	void splash(const char *name);
 

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -53,12 +53,17 @@
 	_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 @@
 	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

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -62,12 +62,46 @@
 	}
 
 	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
 

Modified: scummvm/trunk/engines/parallaction/zone.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/zone.cpp	2007-08-11 14:26:12 UTC (rev 28529)
+++ scummvm/trunk/engines/parallaction/zone.cpp	2007-08-11 17:25:57 UTC (rev 28530)
@@ -92,7 +92,7 @@
 		}
 		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 @@
 	// 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 @@
 
 	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);


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