[Scummvm-cvs-logs] CVS: residual actor.cpp,1.37,1.38 actor.h,1.19,1.20 localize.cpp,1.9,1.10 lua.cpp,1.90,1.91 textobject.cpp,1.14,1.15
Pawel Kolodziejski
aquadran at users.sourceforge.net
Sun Jan 2 05:36:08 CET 2005
- Previous message: [Scummvm-cvs-logs] CVS: residual actor.cpp,1.36,1.37 actor.h,1.18,1.19 costume.cpp,1.22,1.23 lipsynch.cpp,1.5,1.6 lipsynch.h,1.5,1.6 lua.cpp,1.89,1.90 main.cpp,1.42,1.43 resource.cpp,1.20,1.21
- Next message: [Scummvm-cvs-logs] CVS: residual actor.cpp,1.38,1.39
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9683
Modified Files:
actor.cpp actor.h localize.cpp lua.cpp textobject.cpp
Log Message:
changes in parsing message texts
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- actor.cpp 1 Jan 2005 21:07:47 -0000 1.37
+++ actor.cpp 2 Jan 2005 13:34:50 -0000 1.38
@@ -210,29 +210,26 @@
return std::atan2(-dpos.x(), dpos.y()) * (180 / M_PI);
}
-void Actor::sayLine(const char *msg) {
- // TODO - Display text
-
- // Find the message identifier
- if (msg[0] != '/')
- return;
-
- const char *secondSlash = std::strchr(msg + 1, '/');
+void Actor::sayLine(const char *msg, const char *msgId) {
+ assert(msg);
+ assert(msgId);
- if (secondSlash == NULL)
+ if (msg[0] == '/' || msg[0] == 0 || msgId[0] == 0)
return;
- std::string msgText = g_localizer->localize(secondSlash + 1);
- std::string msgId(msg + 1, secondSlash);
+ std::string soundName = msgId;
+ std::string soundLip = msgId;
+ soundName += ".wav";
+ soundLip += ".lip";
- if (_talkSoundName == (msgId + ".wav"))
+ if (_talkSoundName == soundName)
return;
if (g_imuse->getSoundStatus(_talkSoundName.c_str()))
shutUp();
- _lipSynch = g_resourceloader->loadLipSynch((msgId + ".lip").c_str());
- _talkSoundName = msgId + ".wav";
+ _lipSynch = g_resourceloader->loadLipSynch(soundLip.c_str());
+ _talkSoundName = soundName;
g_imuse->startVoice(_talkSoundName.c_str());
_talkAnim = -1;
}
@@ -249,6 +246,7 @@
_lipSynch = NULL;
} else if (_mumbleChore >= 0)
_mumbleCostume->stopChore(_mumbleChore);
+ _talkSoundName = "";
}
void Actor::pushCostume(const char *name) {
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- actor.h 1 Jan 2005 21:07:52 -0000 1.19
+++ actor.h 2 Jan 2005 13:34:50 -0000 1.20
@@ -67,7 +67,7 @@
Vector3d puckVector() const;
void turn(int dir);
- void sayLine(const char *msg);
+ void sayLine(const char *msg, const char *msgId);
void shutUp();
bool talking();
Index: localize.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/localize.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- localize.cpp 1 Jan 2005 12:27:55 -0000 1.9
+++ localize.cpp 2 Jan 2005 13:34:50 -0000 1.10
@@ -81,7 +81,9 @@
}
std::string Localizer::localize(const char *str) const {
- if (str[0] != '/')
+ assert(str);
+
+ if ((str[0] != '/') || (str[0] == 0))
return str;
const char *slash2 = std::strchr(str + 1, '/');
@@ -91,7 +93,7 @@
std::string key(str + 1, slash2 - str - 1);
StringMap::const_iterator i = _entries.find(key);
if (i == _entries.end())
- return str;
+ return slash2 + 1;
- return "/" + key + '/' + i->second;
+ return i->second;
}
Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- lua.cpp 1 Jan 2005 21:07:52 -0000 1.90
+++ lua.cpp 2 Jan 2005 13:34:50 -0000 1.91
@@ -230,14 +230,6 @@
g_registry->set(key, val);
}
-// Localization function
-
-static void LocalizeString() {
- char *str = luaL_check_string(1);
- std::string result = g_localizer->localize(str);
- lua_pushstring(const_cast<char *>(result.c_str()));
-}
-
// Actor functions
static void LoadActor() {
@@ -658,10 +650,70 @@
lua_pushobject(result);
}
+// 0 - translate from '/msgId/'
+// 1 - don't translate - message after '/msgId'
+// 2 - return '/msgId/'
+int translationMode = 0;
+
+std::string parseMsgText(char *msg, char *msgId) {
+ std::string translation = g_localizer->localize(msg);
+ char *secondSlash = NULL;
+
+ if ((msg[0] == '/') && (msgId)) {
+ secondSlash = std::strchr(msg + 1, '/');
+ if (secondSlash != NULL) {
+ strncpy(msgId, msg + 1, secondSlash - msg - 1);
+ msgId[secondSlash - msg - 1] = 0;
+ } else {
+ msgId[0] = 0;
+ }
+ }
+
+ if (translationMode == 1)
+ return secondSlash;
+
+ if (translationMode == 2)
+ return msg;
+
+ return translation;
+}
+
+// Localization function
+
+static void LocalizeString() {
+ char msgId[32];
+ char buf[640];
+
+ char *str = luaL_check_string(1);
+ std::string msg = parseMsgText(str, msgId);
+ sprintf(buf, "/%s/%s", msgId, msg.c_str());
+ lua_pushstring(const_cast<char *>(buf));
+}
+
static void SayLine() {
+ char msgId[32];
+ int pan = 64;
+
Actor *act = check_actor(1);
- const char *msg = luaL_check_string(2);
- act->sayLine(msg);
+
+ int param_number = 2;
+ lua_Object param2 = lua_getparam(param_number++);
+ std::string msg;
+ if (!lua_isnil(param2)) {
+ do {
+ if (lua_isstring(param2)) {
+ char *str = lua_getstring(param2);
+ msg = parseMsgText(str, msgId);
+ } else if (lua_isnumber(param2)) {
+ pan = 0;
+ } else if (lua_istable(param2)) {
+ } else {
+ error("SayLine() unknown type of param");
+ }
+ param2 = lua_getparam(param_number++);
+ } while (!lua_isnil(param2));
+ act->sayLine(msg.c_str(), msgId);
+ }
}
static void InputDialog() {
@@ -1278,43 +1330,6 @@
return value;
}
-// Stub function for builtin functions not yet implemented
-
-static void stubWarning(char *funcName) {
- fprintf(stderr, "WARNING: Stub function %s(", funcName);
- for (int i = 1; ; i++) {
- if (lua_getparam(i) == LUA_NOOBJECT)
- break;
- if (lua_isnil(lua_getparam(i)))
- fprintf(stderr, "nil");
- else if (lua_istable(lua_getparam(i)))
- fprintf(stderr, "{...}");
- else if (lua_isuserdata(lua_getparam(i))) {
- if (lua_tag(lua_getparam(i)) == actor_tag) {
- Actor *a = check_actor(i);
- fprintf(stderr, "<actor \"%s\">", a->name());
- } else if (lua_tag(lua_getparam(i)) == color_tag) {
- Color *c = check_color(i);
- fprintf(stderr, "<color #%02x%02x%02x>", c->red(), c->green(), c->blue());
- } else
- fprintf(stderr, "<userdata %p>", lua_getuserdata(lua_getparam(i)));
- } else if (lua_isfunction(lua_getparam(i)))
- fprintf(stderr, "<function>");
- else if (lua_isnumber(lua_getparam(i)))
- fprintf(stderr, "%g", lua_getnumber(lua_getparam(i)));
- else if (lua_isstring(lua_getparam(i)))
- fprintf(stderr, "\"%s\"", lua_getstring(lua_getparam(i)));
- else
- fprintf(stderr, "<unknown>");
- if (lua_getparam(i+1) != LUA_NOOBJECT)
- fprintf(stderr, ", ");
- }
- fprintf(stderr, ") called\n");
-#if 0
- lua_call("print_stack");
-#endif
-}
-
static void BlastText() {
char * str = luaL_check_string(1), *key_text = NULL;
lua_Object table_obj = lua_getparam(2), key;
@@ -1352,7 +1367,46 @@
error("Unknown BlastText key %s\n", key_text);
}
- warning("STUB: BlastText(\"%s\", x = %d, y = %d)\n", g_localizer->localize(str).c_str(), x, y);
+ char msgId[32];
+ std::string msg = parseMsgText(str, msgId);
+ warning("STUB: BlastText(\"%s\", x = %d, y = %d)\n", msg.c_str(), x, y);
+}
+
+// Stub function for builtin functions not yet implemented
+
+static void stubWarning(char *funcName) {
+ fprintf(stderr, "WARNING: Stub function %s(", funcName);
+ for (int i = 1; ; i++) {
+ if (lua_getparam(i) == LUA_NOOBJECT)
+ break;
+ if (lua_isnil(lua_getparam(i)))
+ fprintf(stderr, "nil");
+ else if (lua_istable(lua_getparam(i)))
+ fprintf(stderr, "{...}");
+ else if (lua_isuserdata(lua_getparam(i))) {
+ if (lua_tag(lua_getparam(i)) == actor_tag) {
+ Actor *a = check_actor(i);
+ fprintf(stderr, "<actor \"%s\">", a->name());
+ } else if (lua_tag(lua_getparam(i)) == color_tag) {
+ Color *c = check_color(i);
+ fprintf(stderr, "<color #%02x%02x%02x>", c->red(), c->green(), c->blue());
+ } else
+ fprintf(stderr, "<userdata %p>", lua_getuserdata(lua_getparam(i)));
+ } else if (lua_isfunction(lua_getparam(i)))
+ fprintf(stderr, "<function>");
+ else if (lua_isnumber(lua_getparam(i)))
+ fprintf(stderr, "%g", lua_getnumber(lua_getparam(i)));
+ else if (lua_isstring(lua_getparam(i)))
+ fprintf(stderr, "\"%s\"", lua_getstring(lua_getparam(i)));
+ else
+ fprintf(stderr, "<unknown>");
+ if (lua_getparam(i+1) != LUA_NOOBJECT)
+ fprintf(stderr, ", ");
+ }
+ fprintf(stderr, ") called\n");
+#if 0
+ lua_call("print_stack");
+#endif
}
#define STUB_FUNC(name) static void name() { stubWarning(#name); }
Index: textobject.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- textobject.cpp 1 Jan 2005 12:27:56 -0000 1.14
+++ textobject.cpp 2 Jan 2005 13:34:50 -0000 1.15
@@ -31,13 +31,11 @@
void TextObject::setY(int y) {_y = y; }
void TextObject::setColor(Color *newcolor) { _fgColor = newcolor; }
+std::string parseMsgText(char *msg, char *msgId);
+
void TextObject::draw() {
- const char *localString = g_localizer->localize(_textID).c_str();
- // This is also used for things like debugging in addition
- // to dialogue so there aren't always translations
- if (strrchr(localString, '/') != NULL) {
- g_driver->drawEmergString(_x, _y, strrchr(localString, '/') + 1, _fgColor);
- } else {
- g_driver->drawEmergString(_x, _y, localString, _fgColor);
- }
+ char msgId[32];
+
+ std::string msg = parseMsgText(_textID, msgId);
+ g_driver->drawEmergString(_x, _y, msg.c_str(), _fgColor);
}
- Previous message: [Scummvm-cvs-logs] CVS: residual actor.cpp,1.36,1.37 actor.h,1.18,1.19 costume.cpp,1.22,1.23 lipsynch.cpp,1.5,1.6 lipsynch.h,1.5,1.6 lua.cpp,1.89,1.90 main.cpp,1.42,1.43 resource.cpp,1.20,1.21
- Next message: [Scummvm-cvs-logs] CVS: residual actor.cpp,1.38,1.39
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list