[Scummvm-cvs-logs] CVS: residual actor.cpp,1.45,1.46 actor.h,1.20,1.21 driver.h,1.3,1.4 driver_gl.cpp,1.37,1.38 driver_gl.h,1.16,1.17 driver_tinygl.cpp,1.7,1.8 driver_tinygl.h,1.3,1.4 engine.cpp,1.65,1.66 engine.h,1.22,1.23 lua.cpp,1.108,1.109 objectstate.cpp,1.5,1.6 textobject.cpp,1.16,1.17 textobject.h,1.7,1.8
Pawel Kolodziejski
aquadran at users.sourceforge.net
Sat Mar 19 13:48:54 CET 2005
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11951
Modified Files:
actor.cpp actor.h driver.h driver_gl.cpp driver_gl.h
driver_tinygl.cpp driver_tinygl.h engine.cpp engine.h lua.cpp
objectstate.cpp textobject.cpp textobject.h
Log Message:
rest of LAF support patch and my addons for driver drawing
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- actor.cpp 14 Jan 2005 09:43:09 -0000 1.45
+++ actor.cpp 19 Mar 2005 21:48:22 -0000 1.46
@@ -22,6 +22,7 @@
#include "lipsynch.h"
#include "localize.h"
#include "driver.h"
+#include "smush.h"
#include "mixer/mixer.h"
@@ -30,6 +31,8 @@
#include <cmath>
#include <cstring>
+Font *Actor::_sayLineFont = NULL;
+
Actor::Actor(const char *name) :
_name(name), _talkColor(255, 255, 255), _pos(0, 0, 0),
_pitch(0), _yaw(0), _roll(0), _walkRate(0), _turnRate(0),
@@ -38,7 +41,7 @@
_walkCostume(NULL), _walkChore(-1), _walkedLast(false), _walkedCur(false),
_turnCostume(NULL), _leftTurnChore(-1), _rightTurnChore(-1),
_lastTurnDir(0), _currTurnDir(0),
- _mumbleCostume(NULL), _mumbleChore(-1) {
+ _mumbleCostume(NULL), _mumbleChore(-1), _sayLineText(NULL) {
g_engine->registerActor(this);
_lookingMode = false;
_constrain = false;
@@ -218,30 +221,40 @@
if (msg[0] == '/' || msg[0] == 0 || msgId[0] == 0)
return;
- std::string soundName = msgId;
- std::string soundLip = msgId;
- soundName += ".wav";
- soundLip += ".lip";
+ // _sayLineText = new TextObject(msg, 10, 20, _sayLineFont, _talkColor);
+ // During movies, SayLine is called for text display only
+ if (!g_smush->isPlaying()) {
+
+ std::string soundName = msgId;
+ std::string soundLip = msgId;
+ soundName += ".wav";
+ soundLip += ".lip";
- if (_talkSoundName == soundName)
- return;
+ if (_talkSoundName == soundName)
+ return;
- if (g_imuse->getSoundStatus(_talkSoundName.c_str()))
- shutUp();
+ if (g_imuse->getSoundStatus(_talkSoundName.c_str()))
+ shutUp();
- _lipSynch = g_resourceloader->loadLipSynch(soundLip.c_str());
- // 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).
- // Also, some lip synch files have no entries
- // In these case, revert to using the mumble chore.
- _talkSoundName = soundName;
- g_imuse->startVoice(_talkSoundName.c_str());
- if (g_engine->currScene()) {
- g_engine->currScene()->setSoundPosition(_talkSoundName.c_str(), pos());
+ // 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).
+ // Also, some lip synch files have no entries
+ // 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;
}
- _talkAnim = -1;
+ if (_sayLineText != NULL) {
+ g_engine->killTextObject(_sayLineText);
+ delete _sayLineText;
+ }
}
bool Actor::talking() {
@@ -377,7 +390,7 @@
if (_lastTurnDir != 0 && _lastTurnDir != _currTurnDir)
_turnCostume->stopChore(getTurnChore(_lastTurnDir));
if (_currTurnDir != 0 && _currTurnDir != _lastTurnDir)
- _turnCostume->playChoreLooping(getTurnChore(_currTurnDir));
+ _turnCostume->playChore(getTurnChore(_currTurnDir));
} else
_currTurnDir = 0;
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- actor.h 2 Jan 2005 13:34:50 -0000 1.20
+++ actor.h 19 Mar 2005 21:48:22 -0000 1.21
@@ -21,12 +21,14 @@
#include "color.h"
#include "vector3d.h"
#include "resource.h"
+#include "font.h"
#include <string>
#include <list>
class Costume;
class LipSynch;
+class TextObject;
class Actor {
public:
@@ -114,6 +116,8 @@
}
void setHead( int joint1, int joint2, int joint3, float maxRoll, float maxPitch, float maxYaw);
+ static void setSayLineFont(Font *font) { _sayLineFont = font; }
+
private:
std::string _name;
std::string _setName;
@@ -156,6 +160,9 @@
Costume *_mumbleCostume;
int _mumbleChore;
+ static Font *_sayLineFont;
+ TextObject *_sayLineText;
+
int getTurnChore(int dir) {
return (dir > 0 ? _rightTurnChore : _leftTurnChore);
}
Index: driver.h
===================================================================
RCS file: /cvsroot/scummvm/residual/driver.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- driver.h 18 Jan 2005 17:24:53 -0000 1.3
+++ driver.h 19 Mar 2005 21:48:23 -0000 1.4
@@ -24,6 +24,7 @@
#include "model.h"
#include "scene.h"
#include "colormap.h"
+#include "font.h"
class Material;
class Bitmap;
@@ -33,6 +34,15 @@
Driver() { ; }
Driver(int screenW, int screenH, int screenBPP) { ; }
+ struct TextObjectHandle {
+ uint16 *bitmapData;
+ void *surface;
+ int numTex;
+ void *texIds;
+ int width;
+ int height;
+ };
+
virtual void setupCamera(float fov, float nclip, float fclip, float roll) = 0;
virtual void positionCamera(Vector3d pos, Vector3d interest) = 0;
@@ -62,6 +72,8 @@
virtual void drawEmergString(int x, int y, const char *text, const Color &fgColor) = 0;
virtual void loadEmergFont() = 0;
+ virtual TextObjectHandle *prepareToTextBitmap(uint8 *bitmap, int width, int height, const Color &fgColor) = 0;
+ virtual void drawTextBitmap(int x, int y, TextObjectHandle *handle) = 0;
virtual void prepareSmushFrame(int width, int height, byte *bitmap) = 0;
virtual void drawSmushFrame(int offsetX, int offsetY) = 0;
Index: driver_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- driver_gl.cpp 18 Mar 2005 19:54:39 -0000 1.37
+++ driver_gl.cpp 19 Mar 2005 21:48:23 -0000 1.38
@@ -18,7 +18,6 @@
#include "debug.h"
#include "colormap.h"
#include "material.h"
-#include "font.h"
#include "driver_gl.h"
DriverGL::DriverGL(int screenW, int screenH, int screenBPP) {
@@ -242,7 +241,7 @@
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, BITMAP_TEXTURE_SIZE, BITMAP_TEXTURE_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
}
- glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_UNPACK_ROW_LENGTH, bitmap->_width);
int cur_tex_idx = bitmap->_numTex * pic;
@@ -543,3 +542,113 @@
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
+
+Driver::TextObjectHandle *DriverGL::prepareToTextBitmap(uint8 *data, int width, int height, const Color &fgColor) {
+ TextObjectHandle *handle = new TextObjectHandle();
+ handle->width = width;
+ handle->height = height;
+ handle->bitmapData = NULL;
+ handle->surface = NULL;
+
+ // create texture
+ handle->numTex = ((width + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE) *
+ ((height + (BITMAP_TEXTURE_SIZE - 1)) / BITMAP_TEXTURE_SIZE);
+ handle->texIds = (GLuint *)new GLuint[handle->numTex];
+ glGenTextures(handle->numTex, (GLuint *)handle->texIds);
+
+ // Convert data to 32-bit RGBA format
+ byte *texData = new byte[4 * width * height];
+ byte *texDataPtr = texData;
+ uint8 *bitmapData = data;
+ for (int i = 0; i < width * height; i++, texDataPtr += 4, bitmapData++) {
+ byte pixel = *bitmapData;
+ if (pixel == 0x00) {
+ texDataPtr[0] = 0;
+ texDataPtr[1] = 0;
+ texDataPtr[2] = 0;
+ texDataPtr[3] = 0;
+ } else if (pixel == 0x80) {
+ texDataPtr[0] = 0;
+ texDataPtr[1] = 0;
+ texDataPtr[2] = 0;
+ texDataPtr[3] = 255;
+ } else if (pixel == 0xFF) {
+ texDataPtr[0] = fgColor.red();
+ texDataPtr[1] = fgColor.green();
+ texDataPtr[2] = fgColor.blue();
+ texDataPtr[3] = 255;
+ }
+ }
+
+ for (int i = 0; i < handle->numTex; i++) {
+ glBindTexture(GL_TEXTURE_2D, ((GLuint *)handle->texIds)[i]);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, BITMAP_TEXTURE_SIZE, BITMAP_TEXTURE_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
+
+ int curTexIdx = 0;
+ for (int y = 0; y < height; y += BITMAP_TEXTURE_SIZE) {
+ for (int x = 0; x < width; x += BITMAP_TEXTURE_SIZE) {
+ int t_width = (x + BITMAP_TEXTURE_SIZE >= width) ? (width - x) : BITMAP_TEXTURE_SIZE;
+ int t_height = (y + BITMAP_TEXTURE_SIZE >= height) ? (height - y) : BITMAP_TEXTURE_SIZE;
+ glBindTexture(GL_TEXTURE_2D, ((GLuint *)handle->texIds)[curTexIdx]);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, t_width, t_height, GL_RGBA, GL_UNSIGNED_BYTE, texData + (y * 4 * width) + (4 * x));
+ curTexIdx++;
+ }
+ }
+
+ delete [] texData;
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ return handle;
+}
+
+void DriverGL::drawTextBitmap(int x, int y, TextObjectHandle *handle) {
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, 640, 480, 0, 0, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable(GL_LIGHTING);
+ glEnable(GL_TEXTURE_2D);
+
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(GL_FALSE);
+ glEnable(GL_SCISSOR_TEST);
+ glScissor(x, 480 - (y + handle->height), handle->width, handle->height);
+ int curTexIdx = 0;
+ for (int t_y = 0; t_y < handle->height; t_y += BITMAP_TEXTURE_SIZE) {
+ for (int t_x = 0; t_x < handle->width; t_x += BITMAP_TEXTURE_SIZE) {
+ GLuint *textures = (GLuint *)handle->texIds;
+ glBindTexture(GL_TEXTURE_2D, textures[curTexIdx]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0, 0.0);
+ glVertex2i(t_x + x, t_y + y);
+ glTexCoord2f(1.0, 0.0);
+ glVertex2i(t_x + x + BITMAP_TEXTURE_SIZE, y + t_y);
+ glTexCoord2f(1.0, 1.0);
+ glVertex2i(t_x + x + BITMAP_TEXTURE_SIZE, y + t_y + BITMAP_TEXTURE_SIZE);
+ glTexCoord2f(0.0, 1.0);
+ glVertex2i(t_x + x, t_y + y + BITMAP_TEXTURE_SIZE);
+ glEnd();
+ curTexIdx++;
+ }
+ }
+
+ glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+ glDepthMask(GL_TRUE);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+}
Index: driver_gl.h
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- driver_gl.h 18 Jan 2005 17:25:04 -0000 1.16
+++ driver_gl.h 19 Mar 2005 21:48:23 -0000 1.17
@@ -63,6 +63,8 @@
void drawEmergString(int x, int y, const char *text, const Color &fgColor);
void loadEmergFont();
+ TextObjectHandle *prepareToTextBitmap(uint8 *bitmap, int width, int height, const Color &fgColor);
+ void drawTextBitmap(int x, int y, TextObjectHandle *handle);
void prepareSmushFrame(int width, int height, byte *bitmap);
void drawSmushFrame(int offsetX, int offsetY);
Index: driver_tinygl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_tinygl.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- driver_tinygl.cpp 6 Mar 2005 15:28:45 -0000 1.7
+++ driver_tinygl.cpp 19 Mar 2005 21:48:23 -0000 1.8
@@ -397,3 +397,47 @@
void DriverTinyGL::drawEmergString(int /*x*/, int /*y*/, const char * /*text*/, const Color &/*fgColor*/) {
}
+
+Driver::TextObjectHandle *DriverTinyGL::prepareToTextBitmap(uint8 *data, int width, int height, const Color &fgColor) {
+ TextObjectHandle *handle = new TextObjectHandle();
+ handle->width = width;
+ handle->height = height;
+ handle->numTex = 0;
+ handle->texIds = NULL;
+
+ // Convert data to 16-bit RGB 565 format
+ uint16 *texData = new uint16[width * height];
+ uint16 *texDataPtr = texData;
+ handle->bitmapData = texData;
+ uint8 *bitmapData = data;
+ for (int i = 0; i < width * height; i++, texDataPtr++, bitmapData++) {
+ byte pixel = *bitmapData;
+ if (pixel == 0x00) {
+ WRITE_LE_UINT16(texDataPtr, 0xf81f);
+ } else if (pixel == 0x80) {
+ *texDataPtr = 0;
+ } else if (pixel == 0xFF) {
+ WRITE_LE_UINT16(texDataPtr, ((fgColor.red() & 0x7) << 8) |
+ ((fgColor.green() & 0x3) << 3) | ((fgColor.blue() & 0x7) >> 3));
+ }
+ }
+
+ handle->surface = SDL_CreateRGBSurfaceFrom(handle->bitmapData, width, height, 16, width * 2, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000);
+
+ return handle;
+}
+
+void DriverTinyGL::drawTextBitmap(int x, int y, TextObjectHandle *handle) {
+ SDL_Rect srcRect, dstRect;
+ srcRect.x = 0;
+ srcRect.y = 0;
+ srcRect.w = handle->width;
+ srcRect.h = handle->height;
+ dstRect.x = x;
+ dstRect.y = y;
+ dstRect.w = handle->width;
+ dstRect.h = handle->height;
+
+ SDL_SetColorKey((SDL_Surface *)handle->surface, SDL_SRCCOLORKEY, 0xf81f);
+ SDL_BlitSurface((SDL_Surface *)handle->surface, &srcRect, _screen, &dstRect);
+}
Index: driver_tinygl.h
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_tinygl.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- driver_tinygl.h 18 Jan 2005 17:25:04 -0000 1.3
+++ driver_tinygl.h 19 Mar 2005 21:48:23 -0000 1.4
@@ -66,6 +66,8 @@
void drawEmergString(int x, int y, const char *text, const Color &fgColor);
void loadEmergFont();
+ TextObjectHandle *prepareToTextBitmap(uint8 *bitmap, int width, int height, const Color &fgColor);
+ void drawTextBitmap(int x, int y, TextObjectHandle *handle);
void prepareSmushFrame(int width, int height, byte *bitmap);
void drawSmushFrame(int offsetX, int offsetY);
Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- engine.cpp 14 Jan 2005 10:53:29 -0000 1.65
+++ engine.cpp 19 Mar 2005 21:48:23 -0000 1.66
@@ -43,7 +43,7 @@
_currScene(NULL), _selectedActor(NULL) {
for (int i = 0; i < SDLK_EXTRA_LAST; i++)
_controlsEnabled[i] = false;
- _speechMode = 2;
+ _speechMode = 2; // VOICE_ONLY
}
void Engine::mainLoop() {
Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- engine.h 12 Jan 2005 23:26:04 -0000 1.22
+++ engine.h 19 Mar 2005 21:48:23 -0000 1.23
@@ -21,6 +21,7 @@
#include "bits.h"
#include "scene.h"
#include "textobject.h"
+#include "font.h"
#include "lua.h"
#include <cstdlib>
Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- lua.cpp 18 Mar 2005 19:54:39 -0000 1.108
+++ lua.cpp 19 Mar 2005 21:48:23 -0000 1.109
@@ -28,6 +28,7 @@
#include "smush.h"
#include "textobject.h"
#include "objectstate.h"
+#include "font.h"
#include "imuse/imuse.h"
@@ -90,7 +91,7 @@
luaL_argerror(num, "color expected");
return NULL;
}
-/*
+
static inline Font *check_font(int num) {
lua_Object param = lua_getparam(num);
if (lua_isuserdata(param) && lua_tag(param) == MKID('FONT'))
@@ -98,7 +99,15 @@
luaL_argerror(num, "font expected");
return NULL;
}
-*/
+
+static inline TextObject *check_textobject(int num) {
+ lua_Object param = lua_getparam(num);
+ if (lua_isuserdata(param) && lua_tag(param) == MKID('TEXT'))
+ return static_cast<TextObject *>(lua_getuserdata(param));
+ luaL_argerror(num, "textobject expected");
+ return NULL;
+}
+
static inline int check_int(int num) {
double val = luaL_check_number(num);
@@ -263,6 +272,31 @@
g_engine->setSelectedActor(act);
}
+static void SetSayLineDefaults() {
+ char *key_text = NULL;
+ lua_Object table_obj = lua_getparam(1);
+ lua_Object key;
+
+ for (;;) {
+ lua_pushobject(table_obj);
+ if (key_text)
+ lua_pushobject(key);
+ else
+ lua_pushnil();
+
+ lua_call("next");
+ key = lua_getresult(1);
+ if (lua_isnil(key))
+ break;
+
+ key_text = lua_getstring(key);
+ if (strstr(key_text, "font"))
+ Actor::setSayLineFont(check_font(2));
+ else
+ error("Unknown SetSayLineDefaults key %s\n", key_text);
+ }
+}
+
static void SetActorTalkColor() {
Actor *act = check_actor(1);
Color *c = check_color(2);
@@ -692,9 +726,9 @@
// 2 - return '/msgId/'
int translationMode = 0;
-std::string parseMsgText(char *msg, char *msgId) {
+std::string parseMsgText(const char *msg, char *msgId) {
std::string translation = g_localizer->localize(msg);
- char *secondSlash = NULL;
+ const char *secondSlash = NULL;
if ((msg[0] == '/') && (msgId)) {
secondSlash = std::strchr(msg + 1, '/');
@@ -1131,6 +1165,7 @@
lua_Object table_obj = lua_getparam(2), key;
int x = 0, y = 0, height = 0, width = 0;
Color *fgColor = NULL;
+ Font *font = NULL;
TextObject *textObject;
for (;;) {
@@ -1153,24 +1188,29 @@
y = atoi(lua_getstring(lua_getresult(2)));
else if (strstr(key_text, "fgcolor"))
fgColor = check_color(2);
- else if (strstr(key_text, "height")) // Hm, do these just force clipping?
+ else if (strstr(key_text, "height"))
height = atoi(lua_getstring(lua_getresult(2)));
else if (strstr(key_text, "width"))
width = atoi(lua_getstring(lua_getresult(2)));
else if (strstr(key_text, "center"))
warning("MakeTextObject key center not implemented");
+ else if (strstr(key_text, "ljustify"))
+ warning("MakeTextObject key ljustify not implemented");
else if (strstr(key_text, "font"))
- warning("MakeTextObject key font not implemented");
+ font = check_font(2);
else
error("Unknown MakeTextObject key %s\n", key_text);
}
- textObject = new TextObject((const char *)line, x, y, *fgColor);
- lua_pushstring(line); // FIXME: Register a LUA text object and pass that instead?
+ // Note: The debug func display_setup_name in _sets.LUA creates an empty TextObject,
+ // and fills it with ChangeTextObject
+
+ textObject = new TextObject((const char *)line, x, y, font, *fgColor);
+ lua_pushusertag(textObject, MKID('TEXT'));
}
static void KillTextObject() {
- char *textID;
+ TextObject *textObjectParm;
if (lua_isnil(lua_getparam(1))) { // FIXME: check this.. nil is kill all lines?
error("KillTextObject(NULL)");
@@ -1178,12 +1218,12 @@
return;
}
- textID = lua_getstring(lua_getparam(1));
+ textObjectParm = check_textobject(1);
for (Engine::TextListType::const_iterator i = g_engine->textsBegin(); i != g_engine->textsEnd(); i++) {
TextObject *textO = *i;
- if (strstr(textO->name(), textID)) {
+ if (strstr(textO->name(), textObjectParm->name())) {
g_engine->killTextObject(textO);
delete textO;
return;
@@ -1232,6 +1272,7 @@
// Main CTO handler and LUA interface
static void ChangeTextObject() {
+ return;
char *textID = lua_getstring(lua_getparam(1));
lua_Object tableObj = lua_getparam(2);
TextObject *modifyObject = NULL;
@@ -1435,7 +1476,7 @@
lua_Object param1 = lua_getparam(1);
if (lua_isstring(param1)) {
char *fontName = lua_getstring(param1);
- void *result = g_resourceloader->loadFont(fontName);
+ Font *result = g_resourceloader->loadFont(fontName);
if (result) {
lua_pushusertag(result, MKID('FONT'));
}
@@ -1617,7 +1658,6 @@
STUB_FUNC(SetTranslationMode)
STUB_FUNC(ExpireText)
STUB_FUNC(PrintLine)
-STUB_FUNC(SetSayLineDefaults)
STUB_FUNC(PurgePrimitiveQueue)
STUB_FUNC(KillPrimitive)
STUB_FUNC(ChangePrimitive)
Index: objectstate.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/objectstate.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- objectstate.cpp 1 Jan 2005 10:23:16 -0000 1.5
+++ objectstate.cpp 19 Mar 2005 21:48:23 -0000 1.6
@@ -25,7 +25,7 @@
int initialImage = 0;
if (visible)
- initialImage = 1;
+ initialImage = 2;
_bitmap->setNumber(initialImage);
if (_zbitmap)
_zbitmap->setNumber(initialImage);
Index: textobject.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- textobject.cpp 12 Jan 2005 18:06:43 -0000 1.16
+++ textobject.cpp 19 Mar 2005 21:48:23 -0000 1.17
@@ -21,21 +21,65 @@
#include "localize.h"
#include "driver.h"
-TextObject::TextObject(const char *text, const int x, const int y, const Color& fgColor) :
+std::string parseMsgText(const char *msg, char *msgId);
+
+TextObject::TextObject(const char *text, const int x, const int y, /*const*/ Font *font, const Color& fgColor) :
_fgColor(fgColor), _x(x), _y(y) {
+
strcpy(_textID, text);
+ char msgId[32];
+ std::string msg = parseMsgText(_textID, msgId);
+
+ // Calculate bitmap dimensions
+ _bitmapHeight = _bitmapWidth = 0;
+
+ for (int i = 0; msg[i] != '\0'; ++i) {
+ _bitmapWidth += font->getCharWidth(msg[i]) + font->getCharStartingCol(msg[i]);
+
+ int h = font->getCharHeight(msg[i]) + font->getCharStartingLine(msg[i]);
+ if (h > _bitmapHeight)
+ _bitmapHeight = h;
+ }
+
+ //printf("creating textobject: %s\nheight: %d\nwidth: %d\n", msg.c_str(), _bitmapHeight, _bitmapWidth);
+
+ _textBitmap = new uint8[_bitmapHeight * _bitmapWidth];
+ memset(_textBitmap, 0, _bitmapHeight * _bitmapWidth);
+
+ // Fill bitmap
+ int offset = 0;
+ for (int line = 0; line < _bitmapHeight; ++line) {
+ for (int c = 0; msg[c] != '\0'; ++c) {
+ uint32 charWidth = font->getCharWidth(msg[c]);
+ uint8 startingCol = font->getCharStartingCol(msg[c]);
+ uint8 startingLine = font->getCharStartingLine(msg[c]);
+
+ if (startingLine < line + 1 && font->getCharHeight(msg[c]) + startingLine > line) {
+ memcpy(_textBitmap + offset + startingCol,
+ font->getCharData(msg[c]) + charWidth * (line - startingLine), charWidth);
+ }
+
+ offset += charWidth + startingCol;
+ }
+ }
+
+ _textObjectHandle = g_driver->prepareToTextBitmap(_textBitmap, _bitmapWidth, _bitmapHeight, _fgColor);
+
g_engine->registerTextObject(this);
}
-void TextObject::setX(int x) {_x = x; }
-void TextObject::setY(int y) {_y = y; }
-void TextObject::setColor(Color *newcolor) { _fgColor = newcolor; }
+TextObject::~TextObject() {
+ delete[] _textBitmap;
+ if (_textObjectHandle->bitmapData)
+ delete _textObjectHandle->bitmapData;
+ if (_textObjectHandle->surface)
+ SDL_FreeSurface((SDL_Surface *)_textObjectHandle->surface);
+ if (_textObjectHandle->texIds)
+ delete _textObjectHandle->texIds;
-std::string parseMsgText(char *msg, char *msgId);
+ delete _textObjectHandle;
+}
void TextObject::draw() {
- char msgId[32];
-
- std::string msg = parseMsgText(_textID, msgId);
- g_driver->drawEmergString(_x, _y, msg.c_str(), _fgColor);
+ g_driver->drawTextBitmap(_x, _y, _textObjectHandle);
}
Index: textobject.h
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- textobject.h 12 Jan 2005 18:06:43 -0000 1.7
+++ textobject.h 19 Mar 2005 21:48:23 -0000 1.8
@@ -19,26 +19,31 @@
#define TEXTOBJECT_H
#include "debug.h"
+#include "font.h"
#include "color.h"
+#include "driver.h"
#include <string>
#include <SDL.h>
-#include "tinygl/gl.h"
-
class TextObject {
public:
- TextObject(const char *text, const int x, const int y, const Color& fgColor);
- void setX(int x);
- void setY(int y);
- void setColor(Color *newColor);
+ TextObject(const char *text, const int x, const int y, /*const*/ Font *font, const Color& fgColor);
+ ~TextObject();
+ void setX(int x) {_x = x; }
+ void setY(int y) {_y = y; }
+ void setColor(Color *newColor) { _fgColor = newColor; }
const char *name() const { return _textID; }
-void draw();
+ void draw();
protected:
- char _textID[10];
Color _fgColor;
int _x, _y;
+ char _textID[10];
+ uint8 *_textBitmap;
+ int _bitmapHeight, _bitmapWidth;
+ Driver::TextObjectHandle *_textObjectHandle;
};
+
#endif
More information about the Scummvm-git-logs
mailing list