[Scummvm-cvs-logs] SF.net SVN: scummvm: [25221] scummvm/trunk/engines/scumm
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Sat Jan 27 02:50:41 CET 2007
Revision: 25221
http://scummvm.svn.sourceforge.net/scummvm/?rev=25221&view=rev
Author: eriktorbjorn
Date: 2007-01-26 17:50:41 -0800 (Fri, 26 Jan 2007)
Log Message:
-----------
Applied my own patch #1640913 ("Loading NUT fonts on demand"), after discussing
it with Fingolfin.
Modified Paths:
--------------
scummvm/trunk/engines/scumm/charset.cpp
scummvm/trunk/engines/scumm/smush/smush_player.cpp
scummvm/trunk/engines/scumm/smush/smush_player.h
Modified: scummvm/trunk/engines/scumm/charset.cpp
===================================================================
--- scummvm/trunk/engines/scumm/charset.cpp 2007-01-27 01:07:12 UTC (rev 25220)
+++ scummvm/trunk/engines/scumm/charset.cpp 2007-01-27 01:50:41 UTC (rev 25221)
@@ -1604,15 +1604,7 @@
_current = 0;
for (int i = 0; i < 5; i++) {
- char fontname[256];
- if ((_vm->_game.id == GID_CMI) && (_vm->_game.features & GF_DEMO) && (i == 4))
- break;
- sprintf(fontname, "font%d.nut", i);
- _fr[i] = new NutRenderer(_vm);
- if (!(_fr[i]->loadFont(fontname, true))) {
- delete _fr[i];
- _fr[i] = NULL;
- }
+ _fr[i] = NULL;
}
}
@@ -1625,8 +1617,16 @@
}
void CharsetRendererNut::setCurID(byte id) {
- assert(id < 5);
+ int numFonts = ((_vm->_game.id == GID_CMI) && (_vm->_game.features & GF_DEMO)) ? 4 : 5;
+ assert(id < numFonts);
_curId = id;
+ if (!_fr[id]) {
+ _fr[id] = new NutRenderer(_vm);
+ char fontname[11];
+ sprintf(fontname, "font%d.nut", id);
+ _fr[id] = new NutRenderer(_vm);
+ _fr[id]->loadFont(fontname, true);
+ }
_current = _fr[id];
assert(_current);
}
Modified: scummvm/trunk/engines/scumm/smush/smush_player.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.cpp 2007-01-27 01:07:12 UTC (rev 25220)
+++ scummvm/trunk/engines/scumm/smush/smush_player.cpp 2007-01-27 01:50:41 UTC (rev 25221)
@@ -574,7 +574,7 @@
if ((!ConfMan.getBool("subtitles")) && ((flags & 8) == 8))
return;
- SmushFont *sf = _sf[0];
+ SmushFont *sf = getFont(0);
int color = 15;
while (*str == '/') {
str++; // For Full Throttle text resources
@@ -600,7 +600,7 @@
{
int id = str[3] - '0';
str += 4;
- sf = _sf[id];
+ sf = getFont(id);
}
break;
case 'c':
@@ -1027,45 +1027,54 @@
}
void SmushPlayer::setupAnim(const char *file) {
- int i;
- char file_font[11];
-
if (_insanity) {
if (!((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformPC)))
readString("mineroad.trs");
} else
readString(file);
+}
+SmushFont *SmushPlayer::getFont(int font) {
+ char file_font[11];
+
+ if (_sf[font])
+ return _sf[font];
+
if (_vm->_game.id == GID_FT) {
if (!((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformPC))) {
- _sf[0] = new SmushFont(_vm, true, false);
- _sf[1] = new SmushFont(_vm, true, false);
- _sf[2] = new SmushFont(_vm, true, false);
- _sf[3] = new SmushFont(_vm, true, false);
- _sf[0]->loadFont("scummfnt.nut", false);
- _sf[1]->loadFont("techfnt.nut", false);
- _sf[2]->loadFont("titlfnt.nut", false);
- _sf[3]->loadFont("specfnt.nut", false);
+ const char *ft_fonts[] = {
+ "scummfnt.nut",
+ "techfnt.nut",
+ "titlfnt.nut",
+ "specfnt.nut"
+ };
+
+ assert(font >= 0 && font < ARRAYSIZE(ft_fonts));
+
+ _sf[font] = new SmushFont(_vm, true, false);
+ _sf[font]->loadFont(ft_fonts[font], false);
}
} else if (_vm->_game.id == GID_DIG) {
if (!(_vm->_game.features & GF_DEMO)) {
- for (i = 0; i < 4; i++) {
- sprintf(file_font, "font%d.nut", i);
- _sf[i] = new SmushFont(_vm, i != 0, false);
- _sf[i]->loadFont(file_font, false);
- }
+ assert(font >= 0 && font < 4);
+
+ sprintf(file_font, "font%d.nut", font);
+ _sf[font] = new SmushFont(_vm, font != 0, false);
+ _sf[font]->loadFont(file_font, false);
}
} else if (_vm->_game.id == GID_CMI) {
- for (i = 0; i < 5; i++) {
- if ((_vm->_game.features & GF_DEMO) && (i == 4))
- break;
- sprintf(file_font, "font%d.nut", i);
- _sf[i] = new SmushFont(_vm, false, true);
- _sf[i]->loadFont(file_font, false);
- }
+ int numFonts = (_vm->_game.features & GF_DEMO) ? 4 : 5;
+ assert(font >= 0 && font < numFonts);
+
+ sprintf(file_font, "font%d.nut", font);
+ _sf[font] = new SmushFont(_vm, false, true);
+ _sf[font]->loadFont(file_font, false);
} else {
- error("SmushPlayer::setupAnim() Unknown font setup for game");
+ error("SmushPlayer::getFont() Unknown font setup for game");
}
+
+ assert(_sf[font]);
+ return _sf[font];
}
void SmushPlayer::parseNextFrame() {
Modified: scummvm/trunk/engines/scumm/smush/smush_player.h
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.h 2007-01-27 01:07:12 UTC (rev 25220)
+++ scummvm/trunk/engines/scumm/smush/smush_player.h 2007-01-27 01:50:41 UTC (rev 25221)
@@ -122,6 +122,7 @@
const char *getString(int id);
private:
+ SmushFont *getFont(int font);
void parseNextFrame();
void init(int32 spped);
void setupAnim(const char *file);
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