DIRECTOR: Make FXmp available to MacText

This commit is contained in:
djsrv
2021-07-05 22:53:35 -04:00
parent b3b55e59e9
commit 831c014f9e
7 changed files with 60 additions and 31 deletions
+1 -4
View File
@@ -102,10 +102,7 @@ Cast::~Cast() {
for (Common::HashMap<uint16, CastMemberInfo *>::iterator it = _castsInfo.begin(); it != _castsInfo.end(); ++it)
delete it->_value;
for (FontXPlatformMap::iterator it = _macFontsToWin.begin(); it != _macFontsToWin.end(); ++it)
delete it->_value;
for (FontXPlatformMap::iterator it = _winFontsToMac.begin(); it != _winFontsToMac.end(); ++it)
for (Graphics::FontXPlatformMap::iterator it = _fontXPlatformMap.begin(); it != _fontXPlatformMap.end(); ++it)
delete it->_value;
delete _loadedStxts;
+8 -13
View File
@@ -31,6 +31,12 @@ namespace Common {
class SeekableReadStreamEndian;
}
namespace Graphics {
struct FontXPlatformInfo;
typedef Common::HashMap<byte, byte> CharMap;
typedef Common::HashMap<uint16, FontXPlatformInfo *> FontXPlatformMap;
}
namespace Director {
class Archive;
@@ -46,15 +52,6 @@ class ScriptCastMember;
class ShapeCastMember;
class TextCastMember;
typedef Common::HashMap<byte, byte> CharMap;
typedef Common::HashMap<uint16, uint16> FontSizeMap;
struct FontXPlatformInfo {
Common::String toFont;
bool remapChars;
FontSizeMap sizeMap;
};
typedef Common::HashMap<Common::String, FontXPlatformInfo *> FontXPlatformMap;
class Cast {
public:
Cast(Movie *movie, uint16 castLibID, bool shared = false);
@@ -104,10 +101,8 @@ public:
uint16 _castLibID;
Common::HashMap<uint16, uint16> _fontMap;
CharMap _macCharsToWin;
CharMap _winCharsToMac;
FontXPlatformMap _macFontsToWin;
FontXPlatformMap _winFontsToMac;
Graphics::CharMap _charMap;
Graphics::FontXPlatformMap _fontXPlatformMap;
Common::HashMap<int, CastMember *> *_loadedCast;
Common::HashMap<int, const Stxt *> *_loadedStxts;
+1 -1
View File
@@ -701,7 +701,7 @@ Graphics::MacWidget *TextCastMember::createWidget(Common::Rect &bbox, Channel *c
dims.right = MIN<int>(dims.right, dims.left + _initialRect.width());
dims.bottom = MIN<int>(dims.bottom, dims.top + _initialRect.height());
}
widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, dims.width(), dims.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow, Common::kMacCentralEurope, _textType == kTextTypeFixed);
widget = new Graphics::MacText(g_director->getCurrentWindow(), bbox.left, bbox.top, dims.width(), dims.height(), g_director->_wm, _ftext, macFont, getForeColor(), getBackColor(), _initialRect.width(), getAlignment(), 0, _borderSize, _gutterSize, _boxShadow, _textShadow, Common::kMacCentralEurope, _textType == kTextTypeFixed, &_cast->_charMap, &_cast->_fontXPlatformMap);
((Graphics::MacText *)widget)->setSelRange(g_director->getCurrentMovie()->_selStart, g_director->getCurrentMovie()->_selEnd);
((Graphics::MacText *)widget)->setEditable(_editable);
((Graphics::MacText *)widget)->draw();
+15 -9
View File
@@ -276,9 +276,11 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
}
Common::String fromFont;
uint16 fromFontId;
tok = readFXmpToken(stream);
if (tok.type == FXMP_TOKEN_WORD || tok.type == FXMP_TOKEN_STRING) {
fromFont = tok.str;
fromFontId = _vm->_wm->_fontMan->registerFontName(fromFont);
tok = readFXmpToken(stream);
}
@@ -332,11 +334,12 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
}
byte toChar = atoi(tok.str.c_str());
// TODO: We should fill _charMap with mappings matching the current platform.
// We only have Mac fonts right now, though, so we'll always use the Win => Mac mappings.
if (fromPlatform == Common::kPlatformMacintosh) {
_macCharsToWin[fromChar] = toChar;
debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Mac char %d to Win char %d", fromChar, toChar);
} else {
_winCharsToMac[fromChar] = toChar;
_charMap[fromChar] = toChar;
debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win char %d to Mac char %d", fromChar, toChar);
}
@@ -344,7 +347,7 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
}
} else {
// font mapping
FontXPlatformInfo *info = new FontXPlatformInfo;
Graphics::FontXPlatformInfo *info = new Graphics::FontXPlatformInfo;
// to font
tok = readFXmpToken(stream);
@@ -353,7 +356,9 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
delete info;
return false;
}
info->toFont = tok.str;
Common::String toFont = tok.str;
uint16 toFontId = _vm->_wm->_fontMan->registerFontName(toFont);
info->toFont = toFontId;
tok = readFXmpToken(stream);
@@ -409,15 +414,16 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
tok = readFXmpToken(stream);
}
// TODO: We should fill _fontXPlatformMap with mappings matching the current platform.
// We only have Mac fonts right now, though, so we'll always use the Win => Mac mappings.
if (fromPlatform == Common::kPlatformMacintosh) {
_macFontsToWin[fromFont] = info;
debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Mac font '%s' to Win font '%s'", fromFont.c_str(), info->toFont.c_str());
debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Mac font '%s' (%d) to Win font '%s' (%d)", fromFont.c_str(), fromFontId, toFont.c_str(), toFontId);
} else {
_winFontsToMac[fromFont] = info;
debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win font '%s' to Mac font '%s'", fromFont.c_str(), info->toFont.c_str());
_fontXPlatformMap[fromFontId] = info;
debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win font '%s' (%d) to Mac font '%s' (%d)", fromFont.c_str(), fromFontId, toFont.c_str(), toFontId);
}
debugC(4, kDebugLoading, " Remap characters: %d", info->remapChars);
for (FontSizeMap::iterator it = info->sizeMap.begin(); it != info->sizeMap.end(); ++it) {
for (Graphics::FontSizeMap::iterator it = info->sizeMap.begin(); it != info->sizeMap.end(); ++it) {
debugC(4, kDebugLoading, " Mapping size %d to %d", it->_key, it->_value);
}
}
+9
View File
@@ -66,6 +66,15 @@ enum {
class Font;
typedef Common::HashMap<byte, byte> CharMap;
typedef Common::HashMap<uint16, uint16> FontSizeMap;
struct FontXPlatformInfo {
uint16 toFont;
bool remapChars;
FontSizeMap sizeMap;
};
typedef Common::HashMap<uint16, FontXPlatformInfo *> FontXPlatformMap;
class MacFont {
public:
MacFont(int id = kMacFontChicago, int size = 12, int slant = kMacFontRegular, FontManager::FontUsage fallback = Graphics::FontManager::kBigGUIFont) {
+17 -2
View File
@@ -94,7 +94,7 @@ uint MacTextLine::getChunkNum(int *col) {
}
MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, bool fixedDims) :
MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, bool fixedDims, CharMap *charMap, FontXPlatformMap *fontXPlatformMap) :
MacWidget(parent, x, y, w, h, wm, true, border, gutter, boxShadow),
_macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
@@ -110,6 +110,9 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
_encodeType = Common::kUtf8;
_plainByteMode = false;
_charMap = charMap;
_fontXPlatformMap = fontXPlatformMap;
if (macFont) {
_defaultFormatting = MacFontRun(this, _wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
@@ -120,7 +123,7 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
init();
}
MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, Common::CodePage encodeType, bool fixedDims) :
MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow, Common::CodePage encodeType, bool fixedDims, CharMap *charMap, FontXPlatformMap *fontXPlatformMap) :
MacWidget(parent, x, y, w, h, wm, true, border, gutter, boxShadow),
_macFont(macFont), _maxWidth(maxWidth), _textAlignment(textAlignment), _interLinear(interlinear) {
@@ -135,6 +138,9 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
_encodeType = encodeType;
_plainByteMode = true;
_charMap = charMap;
_fontXPlatformMap = fontXPlatformMap;
if (macFont) {
_defaultFormatting = MacFontRun(this, _wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
@@ -161,6 +167,9 @@ MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont
_encodeType = Common::kUtf8;
_plainByteMode = false;
_charMap = nullptr;
_fontXPlatformMap = nullptr;
if (macFont) {
_defaultFormatting = MacFontRun(this, _wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
@@ -186,6 +195,9 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m
_encodeType = encodeType;
_plainByteMode = true;
_charMap = nullptr;
_fontXPlatformMap = nullptr;
if (macFont) {
_defaultFormatting = MacFontRun(this, _wm, macFont->getId(), macFont->getSlant(), macFont->getSize(), 0, 0, 0);
_defaultFormatting.font = wm->_fontMan->getFont(*macFont);
@@ -212,6 +224,9 @@ MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const Font *f
_encodeType = Common::kUtf8;
_plainByteMode = false;
_charMap = nullptr;
_fontXPlatformMap = nullptr;
if (font) {
_defaultFormatting = MacFontRun(this, _wm, font, 0, font->getFontHeight(), 0, 0, 0);
_defaultFormatting.font = font;
+9 -2
View File
@@ -39,6 +39,10 @@ class MacText;
class MacWidget;
class MacWindow;
class MacWindowManager;
struct FontXPlatformInfo;
typedef Common::HashMap<byte, byte> CharMap;
typedef Common::HashMap<uint16, FontXPlatformInfo *> FontXPlatformMap;
struct MacFontRun {
Common::U32String text;
@@ -148,8 +152,8 @@ struct SelectedText {
class MacText : public MacWidget {
public:
MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, bool fixedDims = true);
MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, Common::CodePage encodeType = Common::kMacCentralEurope, bool fixedDims = true);
MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, bool fixedDims = true, CharMap *charMap = nullptr, FontXPlatformMap *fontXPlatformMap = nullptr);
MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment = kTextAlignLeft, int interlinear = 0, uint16 border = 0, uint16 gutter = 0, uint16 boxShadow = 0, uint16 textShadow = 0, Common::CodePage encodeType = Common::kMacCentralEurope, bool fixedDims = true, CharMap *charMap = nullptr, FontXPlatformMap *fontXPlatformMap = nullptr);
// 0 pixels between the lines by default
MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear = 0, bool fixedDims = true);
@@ -300,6 +304,9 @@ public:
bool _fullRefresh;
CharMap *_charMap;
FontXPlatformMap *_fontXPlatformMap;
protected:
Common::U32String _str;
const MacFont *_macFont;