patch fixes from Erich Hoover:

subtitles fixes

Thanks
This commit is contained in:
Pawel Kolodziejski 2005-04-03 11:33:28 +00:00
parent c9d2f4caaf
commit c0ce067e56
8 changed files with 46 additions and 36 deletions

3
TODO
View file

@ -1,7 +1,7 @@
Residual TODO list (in rough order of priority):
------------------------------------------------
Assigned tasks:
* Add LAF font and text drawing support (ender)
* Finish text drawing support (salty-horse, aquadran)
* Cross platform GUI for debug input dialogs and path selection (ender)
* Improved walk box code (frob)
* Implement FadeInChore and FadeOutChore (frob)
@ -13,6 +13,5 @@ Unassigned (help wanted):
* Finish Save/Load support for rest of Engine (Lua and iMuse done)
* Implement 2D primitives
* Proper vsscanf implementation in textsplit.cpp for platforms without it (MSVC, etc)
* Fix drawEmergString() to work with Mesa
* Make SMUSH work on Linux/PPC (whats wrong with it, exactly? - ender :)
* Finish panning in 3d position code

View file

@ -266,8 +266,16 @@ void Actor::sayLine(const char *msg, const char *msgId) {
assert(msg);
assert(msgId);
if (msg[0] == '/' || msg[0] == 0 || msgId[0] == 0)
std::string textName = msgId;
textName += ".txt";
if (msg[0] != '/')
warning("Actor::sayLine: Invalid source message (should be an ID)!");
if (msgId[0] == 0) {
error("Actor::sayLine: No message ID for text!");
return;
}
// During movies, SayLine is called for text display only
if (!g_smush->isPlaying()) {
@ -283,6 +291,14 @@ void Actor::sayLine(const char *msg, const char *msgId) {
if (g_imuse->getSoundStatus(_talkSoundName.c_str()))
shutUp();
_talkSoundName = soundName;
g_imuse->startVoice(_talkSoundName.c_str());
if (g_engine->currScene()) {
g_engine->currScene()->setSoundPosition(_talkSoundName.c_str(), pos());
}
// If the actor is clearly not visible then don't try to play the lip synch
if (visible()) {
// Sometimes actors speak offscreen before they, including their
// talk chores are initialized.
// For example, when reading the work order (a LIP file exists for no reason).
@ -290,13 +306,9 @@ void Actor::sayLine(const char *msg, const char *msgId) {
// In these cases, revert to using the mumble chore.
_lipSynch = g_resourceloader->loadLipSynch(soundLip.c_str());
_talkSoundName = soundName;
g_imuse->startVoice(_talkSoundName.c_str());
if (g_engine->currScene()) {
g_engine->currScene()->setSoundPosition(_talkSoundName.c_str(), pos());
}
_talkAnim = -1;
}
}
if (_sayLineText) {
g_engine->killTextObject(_sayLineText);
@ -478,12 +490,6 @@ void Actor::update() {
}
}
if (!talking())
shutUp();
if (!g_imuse->isVoicePlaying())
shutUp();
for (std::list<Costume *>::iterator i = _costumeStack.begin(); i != _costumeStack.end(); i++) {
(*i)->setPosRotate(_pos, _pitch, _yaw, _roll);
(*i)->update();
@ -504,3 +510,9 @@ void Actor::draw() {
g_driver->finishActorDraw();
}
}
// "Undraw objects" (handle objects for actors that may not be on screen)
void Actor::undraw(bool visible) {
if (!talking() || !g_imuse->isVoicePlaying())
shutUp();
}

View file

@ -99,6 +99,7 @@ public:
}
void update();
void draw();
void undraw(bool);
bool isLookAtVectorZero() {
return _lookAtVector.isZero();

View file

@ -210,6 +210,8 @@ void Engine::mainLoop() {
Actor *a = *i;
if (_currScene != NULL && a->inSet(_currScene->name()) && a->visible())
a->draw();
if (_currScene != NULL)
a->undraw(a->inSet(_currScene->name()) && a->visible());
}
}

View file

@ -37,8 +37,10 @@ Localizer::Localizer() {
if (f != NULL)
break;
}
if (f == NULL)
if (f == NULL) {
error("Localizer::Localizer: Unable to find localization information (grim.tab)!");
return;
}
// Get the file size
std::fseek(f, 0, SEEK_END);

15
lua.cpp
View file

@ -768,19 +768,18 @@ static void LocalizeString() {
}
static void SayLine() {
char msgId[32];
char msgId[32], *str;
int pan = 64;
Actor *act = check_actor(1);
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);
str = lua_getstring(param2);
parseMsgText(str, msgId);
} else if (lua_isnumber(param2)) {
pan = 64;
} else if (lua_istable(param2)) {
@ -789,7 +788,7 @@ static void SayLine() {
}
param2 = lua_getparam(param_number++);
} while (!lua_isnil(param2));
act->sayLine(msg.c_str(), msgId);
act->sayLine(str, msgId);
}
}
@ -1252,8 +1251,8 @@ static void KillTextObject() {
static void ChangeTextObject() {
TextObject *textObject = check_textobject(1);
lua_Object tableObj = lua_getparam(2);
TextObject *modifyObject = NULL;
for (Engine::TextListType::const_iterator i = g_engine->textsBegin(); i != g_engine->textsEnd(); i++) {
TextObject *textO = *i;
@ -1262,18 +1261,16 @@ static void ChangeTextObject() {
break;
}
}
if (!modifyObject)
error("ChangeTextObject(): Cannot find active text object");
modifyObject->destroyBitmap();
textObject->setDefaults(&textObjectDefaults);
// textObject->setDefaults(&textObjectDefaults);
if (lua_istable(tableObj))
getTextObjectParams(modifyObject, tableObj);
modifyObject->createBitmap();
g_engine->registerTextObject(modifyObject);
lua_pushnumber(modifyObject->getBitmapWidth());
lua_pushnumber(modifyObject->getBitmapHeight());

View file

@ -29,9 +29,9 @@ TextObjectDefaults textObjectDefaults;
TextObject::TextObject() :
_created(false), _x(0), _y(0), _width(0), _height(0), _justify(0),
_font(NULL), _text(NULL), _textBitmap(NULL), _bitmapWidth(0),
_font(NULL), _textBitmap(NULL), _bitmapWidth(0),
_bitmapHeight(0), _textObjectHandle(NULL) {
memset(_textID, 0, 10);
memset(_textID, 0, sizeof(_textID));
_fgColor._vals[0] = 0;
_fgColor._vals[1] = 0;
_fgColor._vals[2] = 0;
@ -55,9 +55,7 @@ void TextObject::createBitmap() {
if (_created)
destroyBitmap();
strcpy(_textID, _text);
char msgId[32];
std::string msg = parseMsgText(_textID, msgId);
std::string msg = parseMsgText(_textID, NULL);
_bitmapWidth = 0;
_bitmapHeight = 0;
@ -85,7 +83,7 @@ void TextObject::createBitmap() {
uint8 startingLine = _font->getCharStartingLine(msg[c]);
if (startingLine < line + 1 && _font->getCharHeight(msg[c]) + startingLine > line) {
memcpy(_textBitmap + offset + startingCol,
memcpy(&_textBitmap[offset + startingCol],
_font->getCharData(msg[c]) + charWidth * (line - startingLine), charWidth);
}

View file

@ -45,7 +45,7 @@ public:
void createBitmap();
void destroyBitmap();
void setDefaults(TextObjectDefaults *defaults);
void setText(char *text) { _text = text; }
void setText(char *text) { strcpy(_textID, text); }
void setX(int x) { _x = x; }
void setY(int y) { _y = y; }
void setWidth(int width) { _width = width; }
@ -72,7 +72,6 @@ protected:
uint _width, _height;
int _justify;
Font *_font;
char *_text;
char _textID[32];
uint8 *_textBitmap;
uint _bitmapWidth, _bitmapHeight;