DIRECTOR: Move loadFontMap to fonts.cpp

There is going to be quite a bit of code to handle font mapping, so I've
created a new file for it.
This commit is contained in:
djsrv 2021-07-03 23:06:53 -04:00
parent 957abce35b
commit d4882d2daa
3 changed files with 66 additions and 32 deletions

View File

@ -1169,36 +1169,4 @@ void Cast::loadCastInfo(Common::SeekableReadStreamEndian &stream, uint16 id) {
_castsInfo[id] = ci;
}
void Cast::loadFontMap(Common::SeekableReadStreamEndian &stream) {
if (stream.size() == 0)
return;
debugC(2, kDebugLoading, "****** Loading FontMap VWFM");
uint16 count = stream.readUint16();
uint32 offset = (count * 2) + 2;
uint32 currentRawPosition = offset;
for (uint16 i = 0; i < count; i++) {
uint16 id = stream.readUint16();
uint32 positionInfo = stream.pos();
stream.seek(currentRawPosition);
uint16 size = stream.readByte();
Common::String font;
for (uint16 k = 0; k < size; k++) {
font += stream.readByte();
}
// Map cast font ID to window manager font ID
_fontMap[id] = _vm->_wm->_fontMan->registerFontName(font);
debugC(3, kDebugLoading, "Fontmap. ID %d Font %s", id, font.c_str());
currentRawPosition = stream.pos();
stream.seek(positionInfo);
}
}
} // End of namespace Director

View File

@ -0,0 +1,65 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "common/substream.h"
#include "graphics/macgui/macfontmanager.h"
#include "graphics/macgui/macwindowmanager.h"
#include "director/director.h"
#include "director/cast.h"
namespace Director {
void Cast::loadFontMap(Common::SeekableReadStreamEndian &stream) {
if (stream.size() == 0)
return;
debugC(2, kDebugLoading, "****** Loading FontMap VWFM");
uint16 count = stream.readUint16();
uint32 offset = (count * 2) + 2;
uint32 currentRawPosition = offset;
for (uint16 i = 0; i < count; i++) {
uint16 id = stream.readUint16();
uint32 positionInfo = stream.pos();
stream.seek(currentRawPosition);
uint16 size = stream.readByte();
Common::String font;
for (uint16 k = 0; k < size; k++) {
font += stream.readByte();
}
// Map cast font ID to window manager font ID
_fontMap[id] = _vm->_wm->_fontMan->registerFontName(font);
debugC(3, kDebugLoading, "Fontmap. ID %d Font %s", id, font.c_str());
currentRawPosition = stream.pos();
stream.seek(positionInfo);
}
}
} // End of namespace Director

View File

@ -8,6 +8,7 @@ MODULE_OBJS = \
cursor.o \
director.o \
events.o \
fonts.o \
frame.o \
graphics.o \
images.o \