aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2005-04-28 22:17:23 +0000
committerMax Horn2005-04-28 22:17:23 +0000
commitc5127d3c05ec1dccb8ead61d38727e3e98dce6d1 (patch)
treef78e52873c734ef65db64012c2de532035d4d8fd
parente8865cc596a19c8604f37432dd890138185b18f9 (diff)
downloadscummvm-rg350-c5127d3c05ec1dccb8ead61d38727e3e98dce6d1.tar.gz
scummvm-rg350-c5127d3c05ec1dccb8ead61d38727e3e98dce6d1.tar.bz2
scummvm-rg350-c5127d3c05ec1dccb8ead61d38727e3e98dce6d1.zip
Moved bundle based localization code to ScummEngine_v7
svn-id: r17855
-rw-r--r--scumm/actor.cpp10
-rw-r--r--scumm/intern.h14
-rw-r--r--scumm/scumm.cpp18
-rw-r--r--scumm/scumm.h20
-rw-r--r--scumm/string.cpp10
5 files changed, 47 insertions, 25 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index 7f797e9309..24e74ec8cb 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -1301,14 +1301,18 @@ int ScummEngine::getActorFromPos(int x, int y) {
return result;
}
+void ScummEngine_v7::actorTalk(const byte *msg) {
+ ScummEngine::actorTalk(msg);
+
+ // Play associated speech, if any
+ playSpeech((byte *)_lastStringTag);
+}
+
void ScummEngine::actorTalk(const byte *msg) {
Actor *a;
addMessageToStack(msg, _charsetBuffer, sizeof(_charsetBuffer));
- // Play associated speech, if any
- playSpeech((byte *)_lastStringTag);
-
// FIXME: Workaround for bugs #770039 and #770049
if (_gameId == GID_LOOM || _gameId == GID_LOOM256) {
if (!*_charsetBuffer)
diff --git a/scumm/intern.h b/scumm/intern.h
index 8d41c5f231..72e722aa31 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -1254,7 +1254,14 @@ protected:
class ScummEngine_v7 : public ScummEngine_v6 {
public:
- ScummEngine_v7(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v6(detector, syst, gs, md5sum) {}
+ ScummEngine_v7(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]);
+ ~ScummEngine_v7();
+
+ bool _existLanguageFile;
+ char *_languageBuffer;
+ LangIndexNode *_languageIndex;
+ int _languageIndexSize;
+ char _lastStringTag[12+1];
protected:
virtual void setupScummVars();
@@ -1272,6 +1279,11 @@ protected:
virtual void panCameraTo(int x, int y);
virtual int getObjectIdFromOBIM(const byte *obim);
+
+ virtual void actorTalk(const byte *msg);
+ virtual void translateText(const byte *text, byte *trans_buff);
+ virtual void loadLanguageBundle();
+ void playSpeech(const byte *ptr);
};
class ScummEngine_v8 : public ScummEngine_v7 {
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index 95a39ef6c2..7de23d0d3e 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -904,9 +904,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS
_NES_lastTalkingActor = 0;
_NES_talkColor = 0;
_keepText = false;
- _existLanguageFile = false;
- _languageBuffer = NULL;
- _languageIndex = NULL;
_costumeLoader = NULL;
_costumeRenderer = NULL;
_2byteFontPtr = 0;
@@ -1189,7 +1186,6 @@ ScummEngine::~ScummEngine() {
delete _fileHandle;
delete _sound;
- free(_languageBuffer);
delete _costumeLoader;
delete _costumeRenderer;
@@ -1214,8 +1210,6 @@ ScummEngine::~ScummEngine() {
free(_classData);
free(_arraySlot);
- free(_languageIndex);
-
free(_compositeBuf);
free(_herculesBuf);
@@ -1304,6 +1298,18 @@ ScummEngine_v80he::ScummEngine_v80he(GameDetector *detector, OSystem *syst, cons
_heSBNGId = 0;
}
+ScummEngine_v7::ScummEngine_v7(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16])
+ : ScummEngine_v6(detector, syst, gs, md5sum) {
+ _existLanguageFile = false;
+ _languageBuffer = NULL;
+ _languageIndex = NULL;
+}
+
+ScummEngine_v7::~ScummEngine_v7() {
+ free(_languageBuffer);
+ free(_languageIndex);
+}
+
ScummEngine_v8::ScummEngine_v8(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16])
: ScummEngine_v7(detector, syst, gs, md5sum) {
_objectIDMap = 0;
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 0c7335c6b9..9929badfbb 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -851,7 +851,7 @@ public:
int _NES_lastTalkingActor;
int _NES_talkColor;
- void actorTalk(const byte *msg);
+ virtual void actorTalk(const byte *msg);
void stopTalk();
int getTalkingActor(); // Wrapper around VAR_TALK_ACTOR for V1 Maniac
void setTalkingActor(int variable);
@@ -1164,19 +1164,13 @@ protected:
int addNameToStack(byte *dst, int dstSize, int var);
int addStringToStack(byte *dst, int dstSize, int var);
+ virtual void loadLanguageBundle() {}
+
public:
- Common::Language _language;
-protected:
- bool _existLanguageFile;
- char *_languageBuffer;
- LangIndexNode *_languageIndex;
- int _languageIndexSize;
- char _lastStringTag[12+1];
-
- void loadLanguageBundle();
- void playSpeech(const byte *ptr);
-public:
- void translateText(const byte *text, byte *trans_buff); // Used by class ScummDialog
+ Common::Language _language; // Accessed by a hack in NutRenderer::loadFont
+
+ // Used by class ScummDialog:
+ virtual void translateText(const byte *text, byte *trans_buff);
// Somewhat hackish stuff for 2 byte support (Chinese/Japanese/Korean)
bool _useCJKMode;
diff --git a/scumm/string.cpp b/scumm/string.cpp
index c5cbc0df1e..e4cc689169 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -29,6 +29,7 @@
#include "scumm/charset.h"
#include "scumm/dialogs.h"
#include "scumm/imuse_digi/dimuse.h"
+#include "scumm/intern.h"
#include "scumm/verbs.h"
#include "scumm/sound.h"
#include "scumm/util.h"
@@ -827,7 +828,7 @@ int indexCompare(const void *p1, const void *p2) {
}
// Create an index of the language file.
-void ScummEngine::loadLanguageBundle() {
+void ScummEngine_v7::loadLanguageBundle() {
ScummFile file;
int32 size;
@@ -956,7 +957,7 @@ void ScummEngine::loadLanguageBundle() {
qsort(_languageIndex, _languageIndexSize, sizeof(LangIndexNode), indexCompare);
}
-void ScummEngine::playSpeech(const byte *ptr) {
+void ScummEngine_v7::playSpeech(const byte *ptr) {
if ((_gameId == GID_DIG || _gameId == GID_CMI) && ptr[0]) {
char pointer[20];
strcpy(pointer, (const char *)ptr);
@@ -973,6 +974,11 @@ void ScummEngine::playSpeech(const byte *ptr) {
}
void ScummEngine::translateText(const byte *text, byte *trans_buff) {
+ // Default: just copy the string
+ memcpy(trans_buff, text, resStrLen(text) + 1);
+}
+
+void ScummEngine_v7::translateText(const byte *text, byte *trans_buff) {
LangIndexNode target;
LangIndexNode *found = NULL;
int i;