mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
NEVERHOOD: Offset fonts when using left-centered nhc translations
This commit is contained in:
parent
e70e91a8e2
commit
0ca10425b6
@ -668,12 +668,16 @@ void Scene1005::drawTextToBackground() {
|
||||
} else {
|
||||
TextResource textResource(_vm);
|
||||
const char *textStart, *textEnd;
|
||||
int16 y = 36;
|
||||
int16 x = 188, y = 36;
|
||||
FontSurface *fontSurface = FontSurface::createFontSurface(_vm, getGlobalVar(V_ENTRANCE_OPEN) ? 0x283CE401 : 0xC6604282);
|
||||
textResource.load(0x80283101);
|
||||
textStart = textResource.getString(textIndex, textEnd);
|
||||
if (_vm->shouldOffsetFontNhc()) {
|
||||
x += 15;
|
||||
y += 18;
|
||||
}
|
||||
while (textStart < textEnd) {
|
||||
fontSurface->drawString(_background->getSurface(), 188, y, (const byte*)textStart);
|
||||
fontSurface->drawString(_background->getSurface(), x, y, (const byte*)textStart);
|
||||
y += 36;
|
||||
textStart += strlen(textStart) + 1;
|
||||
}
|
||||
|
@ -1455,7 +1455,11 @@ void Scene2208::drawRow(int16 rowIndex) {
|
||||
_background->getSurface()->copyFrom(_backgroundSurface->getSurface(), 0, y, sourceRect);
|
||||
if (rowIndex < (int)_strings.size()) {
|
||||
const char *text = _strings[rowIndex];
|
||||
_fontSurface->drawString(_background->getSurface(), 95, y, (const byte*)text);
|
||||
int16 x = 95;
|
||||
if (_vm->shouldOffsetFontNhc()) {
|
||||
x += 15;
|
||||
}
|
||||
_fontSurface->drawString(_background->getSurface(), x, y, (const byte*)text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
namespace Neverhood {
|
||||
|
||||
NeverhoodEngine::NeverhoodEngine(OSystem *syst, const ADGameDescription *gameDesc) :
|
||||
Engine(syst), _gameDescription(gameDesc), _haveSubtitles(false) {
|
||||
Engine(syst), _gameDescription(gameDesc), _haveSubtitles(false), _nhcOffsetFont(false) {
|
||||
// Setup mixer
|
||||
if (!_mixer->isReady()) {
|
||||
warning("Sound initialization failed.");
|
||||
@ -102,6 +102,16 @@ Common::Error NeverhoodEngine::run() {
|
||||
|
||||
Common::String nhcFile = ConfMan.get("nhc_file");
|
||||
if (!nhcFile.empty() && _res->addNhcArchive("language/" + nhcFile + ".nhc")) {
|
||||
uint32 fontSpecHash = calcHash("asRecFont");
|
||||
if (_res->nhcExists(fontSpecHash, kResTypeData)) {
|
||||
DataResource fontData(this);
|
||||
fontData.load(fontSpecHash);
|
||||
|
||||
_nhcOffsetFont = (fontData.getPoint(calcHash("meNumRows")).x == 14
|
||||
&& fontData.getPoint(calcHash("meFirstChar")).x == 32
|
||||
&& fontData.getPoint(calcHash("meCharHeight")).x == 34
|
||||
&& fontData.getPointArray(calcHash("meTracking"))->size() == 224);
|
||||
}
|
||||
if (ConfMan.getBool("subtitles")) {
|
||||
Common::SeekableReadStream *s = _res->createNhcStream(0x544E4F46, kResNhcTypeSubFont);
|
||||
if (s && s->size() >= 4096) {
|
||||
|
@ -138,6 +138,7 @@ public:
|
||||
void toggleSoundUpdate(bool state) { _updateSound = state; }
|
||||
void toggleMusic(bool state) { _enableMusic = state; }
|
||||
bool musicIsEnabled() { return _enableMusic; }
|
||||
bool shouldOffsetFontNhc() const { return _nhcOffsetFont; }
|
||||
|
||||
const SubtitleGlyph *getSubfont() const {
|
||||
return _haveSubtitles ? _subFont : nullptr;
|
||||
@ -146,6 +147,7 @@ public:
|
||||
private:
|
||||
bool _updateSound;
|
||||
bool _enableMusic;
|
||||
bool _nhcOffsetFont;
|
||||
|
||||
SubtitleGlyph _subFont[256];
|
||||
bool _haveSubtitles;
|
||||
|
@ -122,6 +122,15 @@ Common::SeekableReadStream *ResourceMan::createNhcStream(uint32 fileHash, uint32
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ResourceMan::nhcExists(uint32 fileHash, uint32 type) {
|
||||
ResourceFileEntry *entry = findEntry(fileHash);
|
||||
if (!entry)
|
||||
return false;
|
||||
if (entry->nhcArchiveEntry && entry->nhcArchive && entry->nhcArchiveEntry->type == type)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ResourceMan::queryResource(uint32 fileHash, ResourceHandle &resourceHandle) {
|
||||
ResourceFileEntry *firstEntry;
|
||||
resourceHandle._resourceFileEntry = findEntry(fileHash, &firstEntry);
|
||||
|
@ -114,6 +114,7 @@ public:
|
||||
ResourceFileEntry *findEntry(uint32 fileHash, ResourceFileEntry **firstEntry = NULL);
|
||||
Common::SeekableReadStream *createStream(uint32 fileHash);
|
||||
Common::SeekableReadStream *createNhcStream(uint32 fileHash, uint32 type);
|
||||
bool nhcExists(uint32 fileHash, uint32 type);
|
||||
const ResourceFileEntry& getEntry(uint index) { return _entries[index]; }
|
||||
uint getEntryCount() { return _entries.size(); }
|
||||
void queryResource(uint32 fileHash, ResourceHandle &resourceHandle);
|
||||
|
Loading…
Reference in New Issue
Block a user