Merge pull request #108 from klusark/includes

Cleaned up dependencies between files.
This commit is contained in:
Pawel Kolodziejski 2011-05-13 23:00:56 -07:00
commit 0e24524395
44 changed files with 197 additions and 99 deletions

View File

@ -39,6 +39,8 @@
#include "engines/grim/smush/video.h"
#include "engines/grim/imuse/imuse.h"
#include "engines/grim/lua.h"
#include "engines/grim/resource.h"
#include "engines/grim/savegame.h"
namespace Grim {

View File

@ -27,15 +27,16 @@
#define GRIM_ACTOR_H
#include "engines/grim/object.h"
#include "engines/grim/color.h"
#include "engines/grim/resource.h"
#include "engines/grim/savegame.h"
#include "graphics/vector3d.h"
namespace Grim {
class TextObject;
class Sector;
class Costume;
class LipSync;
class Font;
class Color;
typedef Common::List<Sector *> SectorListType;
@ -192,7 +193,7 @@ private:
float _scale;
bool _lookingMode;
Common::String _talkSoundName;
LipSyncPtr _lipSync;
ObjectPtr<LipSync> _lipSync;
Common::List<Costume *> _costumeStack;
// Variables for gradual turning
@ -228,7 +229,7 @@ private:
Shadow *_shadowArray;
int _activeShadowSlot;
static FontPtr _sayLineFont;
static ObjectPtr<Font> _sayLineFont;
TextObject *_sayLineText;
// Validate a yaw angle then set it appropriately

View File

@ -26,7 +26,6 @@
#ifndef GRIM_BITMAP_H
#define GRIM_BITMAP_H
#include "engines/grim/resource.h"
#include "engines/grim/object.h"
namespace Grim {

View File

@ -27,7 +27,6 @@
#define GRIM_COLOR_H
#include "common/scummsys.h"
#include "engines/grim/savegame.h"
#include "engines/grim/object.h"
namespace Grim {

55
engines/grim/colormap.cpp Normal file
View File

@ -0,0 +1,55 @@
/* Residual - A 3D game interpreter
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
* $URL$
* $Id$
*
*/
#include "engines/grim/colormap.h"
#include "engines/grim/resource.h"
namespace Grim {
// Load a colormap from the given data.
CMap::CMap(const char *fileName, const char *data, int len) :
Object() {
_fname = fileName;
if (len < 4 || READ_BE_UINT32(data) != MKTAG('C','M','P',' '))
error("Invalid magic loading colormap");
memcpy(_colors, data + 64, sizeof(_colors));
}
CMap::CMap() : Object() {}
CMap::~CMap() {
if (g_resourceloader)
g_resourceloader->uncacheColormap(this);
}
bool CMap::operator==(const CMap &c) const {
if (_fname != c._fname) {
return false;
}
return true;
}
} // end of namespace Grim

View File

@ -26,9 +26,6 @@
#ifndef GRIM_COLORMAP_H
#define GRIM_COLORMAP_H
#include "common/endian.h"
#include "engines/grim/resource.h"
#include "engines/grim/object.h"
namespace Grim {
@ -36,31 +33,16 @@ namespace Grim {
class CMap : public Object {
public:
// Load a colormap from the given data.
CMap(const char *fileName, const char *data, int len) :
Object() {
_fname = fileName;
if (len < 4 || READ_BE_UINT32(data) != MKTAG('C','M','P',' '))
error("Invalid magic loading colormap");
memcpy(_colors, data + 64, sizeof(_colors));
}
CMap() : Object() {}
~CMap() {
if (g_resourceloader)
g_resourceloader->uncacheColormap(this);
}
CMap(const char *fileName, const char *data, int len);
CMap();
~CMap();
const char *getFilename() const { return _fname.c_str(); }
// The color data, in RGB format
char _colors[256 * 3];
Common::String _fname;
bool operator==(const CMap &c) const {
if (_fname != c._fname) {
return false;
}
return true;
}
bool operator==(const CMap &c) const;
};
} // end of namespace Grim

View File

@ -36,6 +36,8 @@
#include "engines/grim/material.h"
#include "engines/grim/lua.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/resource.h"
#include "engines/grim/savegame.h"
#include "engines/grim/imuse/imuse.h"
@ -149,7 +151,7 @@ public:
protected:
Common::String _filename;
ModelPtr _obj;
ObjectPtr<Model> _obj;
Model::HierNode *_hier;
Graphics::Matrix4 _matrix;
};

View File

@ -28,9 +28,8 @@
#include "common/memstream.h"
#include "engines/grim/model.h"
#include "engines/grim/object.h"
#include "engines/grim/colormap.h"
#include "engines/grim/model.h"
namespace Grim {
@ -38,6 +37,8 @@ namespace Grim {
typedef uint32 tag32;
class TextSplitter;
class Costume : public Object {
public:
Costume(const char *filename, const char *data, int len, Costume *prevCost);
@ -101,7 +102,7 @@ public:
virtual ~Component() { }
protected:
CMapPtr _cmap, _previousCmap;
ObjectPtr<CMap> _cmap, _previousCmap;
tag32 _tag;
int _parentID;
bool _visible;
@ -183,7 +184,7 @@ private:
friend class Costume;
};
CMapPtr _cmap;
ObjectPtr<CMap> _cmap;
int _numChores;
Chore *_chores;
Graphics::Matrix4 _matrix;

View File

@ -30,6 +30,7 @@
#include "engines/grim/font.h"
#include "engines/grim/lua.h"
#include "engines/grim/colormap.h"
#include "engines/grim/resource.h"
namespace Grim {

View File

@ -26,7 +26,6 @@
#ifndef GRIM_FONT_H
#define GRIM_FONT_H
#include "engines/grim/resource.h"
#include "engines/grim/object.h"
namespace Grim {

View File

@ -25,6 +25,7 @@
#include "engines/grim/gfx_base.h"
#include "engines/grim/savegame.h"
#include "engines/grim/colormap.h"
namespace Grim {

View File

@ -26,15 +26,15 @@
#ifndef GRIM_GFX_BASE_H
#define GRIM_GFX_BASE_H
#include "engines/grim/colormap.h"
#include "engines/grim/model.h"
#include "engines/grim/scene.h"
#include "engines/grim/primitives.h"
namespace Grim {
struct Shadow;
class SaveGame;
class BitmapData;
class PrimitiveObject;
class GfxBase {
public:

View File

@ -39,6 +39,8 @@
#include "engines/grim/gfx_opengl.h"
#include "engines/grim/grim.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/primitives.h"
#ifdef USE_OPENGL

View File

@ -33,6 +33,8 @@
#include "engines/grim/gfx_tinygl.h"
#include "engines/grim/grim.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/primitives.h"
namespace Grim {

View File

@ -61,6 +61,10 @@
#include "engines/grim/costume.h"
#include "engines/grim/material.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/lab.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/font.h"
#include "engines/grim/primitives.h"
#include "engines/grim/lua/lualib.h"

View File

@ -28,12 +28,22 @@
#include "engines/engine.h"
#include "common/str-array.h"
#include "common/hashmap.h"
#include "engines/grim/textobject.h"
namespace Grim {
class Actor;
class SaveGame;
class Bitmap;
class Font;
class Color;
class ObjectState;
class Scene;
class TextObject;
class PrimitiveObject;
enum enDebugLevels {
DEBUG_NONE, DEBUG_NORMAL, DEBUG_WARN, DEBUG_ERROR, DEBUG_LUA, DEBUG_BITMAPS, DEBUG_MODEL, DEBUG_STUB,
@ -236,9 +246,7 @@ public:
Common::StringArray _listFiles;
Common::StringArray::const_iterator _listFilesIter;
TextObjectDefaults _sayLineDefaults;
TextObjectDefaults _printLineDefaults;
TextObjectDefaults _blastTextDefaults;
TextObjectDefaults _sayLineDefaults, _printLineDefaults, _blastTextDefaults;
private:

View File

@ -27,6 +27,7 @@
#include "engines/grim/grim.h"
#include "engines/grim/colormap.h"
#include "engines/grim/resource.h"
#include "engines/grim/imuse/imuse_mcmp_mgr.h"

View File

@ -27,6 +27,7 @@
#include "engines/grim/grim.h"
#include "engines/grim/resource.h"
#include "engines/grim/lab.h"
#include "engines/grim/colormap.h"
#include "engines/grim/imuse/imuse_sndmgr.h"

View File

@ -31,6 +31,7 @@
#include "engines/grim/keyframe.h"
#include "engines/grim/textsplit.h"
#include "engines/grim/colormap.h"
#include "engines/grim/resource.h"
namespace Grim {

View File

@ -26,7 +26,6 @@
#ifndef GRIM_KEYFRAME_H
#define GRIM_KEYFRAME_H
#include "engines/grim/model.h"
#include "engines/grim/object.h"
namespace Grim {

View File

@ -26,6 +26,7 @@
#include "common/endian.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/resource.h"
namespace Grim {

View File

@ -26,7 +26,6 @@
#ifndef GRIM_LIPSYNC_H
#define GRIM_LIPSYNC_H
#include "engines/grim/resource.h"
#include "engines/grim/object.h"
namespace Grim {

View File

@ -37,6 +37,9 @@
#include "engines/grim/colormap.h"
#include "engines/grim/grim.h"
#include "engines/grim/savegame.h"
#include "engines/grim/resource.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/font.h"
#include "engines/grim/lua/lauxlib.h"
#include "engines/grim/lua/luadebug.h"

View File

@ -30,6 +30,10 @@
#include "engines/grim/grim.h"
#include "engines/grim/lua.h"
#include "engines/grim/resource.h"
#include "engines/grim/colormap.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/primitives.h"
#include "engines/grim/smush/video.h"

View File

@ -27,6 +27,8 @@
#include "engines/grim/lua.h"
#include "engines/grim/actor.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/savegame.h"
#include "engines/grim/colormap.h"
#include "engines/grim/imuse/imuse.h"

View File

@ -31,6 +31,8 @@
#include "engines/grim/localize.h"
#include "engines/grim/actor.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/savegame.h"
#include "engines/grim/colormap.h"
#include "engines/grim/imuse/imuse.h"

View File

@ -118,7 +118,7 @@ void L2_PlayActorChore() {
const char *choreName = lua_getstring(choreObj);
const char *costumeName = lua_getstring(costumeObj);
warning("L2_PlayActorChore: implement opcode actor: %s, chore: %s, costume: %s, mode bool: %d, param: %f",
warning("L2_PlayActorChore: implement opcode actor: %s, chore: %s, costume: %s, mode bool: %d, param: %f",
actor->getName(), choreName, costumeName, (int)mode, param);
// FIXME. code below is a hack, need proper implementation
actor->setCostume(costumeName);

View File

@ -28,6 +28,7 @@
#include "engines/grim/grim.h"
#include "engines/grim/material.h"
#include "engines/grim/gfx_base.h"
#include "engines/grim/resource.h"
namespace Grim {

View File

@ -26,12 +26,12 @@
#ifndef GRIM_MATERIAL_H
#define GRIM_MATERIAL_H
#include "engines/grim/resource.h"
#include "engines/grim/object.h"
#include "engines/grim/colormap.h"
namespace Grim {
class CMAp;
class Material : public Object {
public:
Material() { _width = 0; }
@ -52,7 +52,7 @@ public:
Common::String _fname;
const CMapPtr _cmap;
const ObjectPtr<CMap> _cmap;
int _numImages, _currImage;
int _width, _height;
void *_textures;

View File

@ -32,6 +32,7 @@
#include "engines/grim/textsplit.h"
#include "engines/grim/gfx_base.h"
#include "engines/grim/lipsync.h"
#include "engines/grim/resource.h"
namespace Grim {

View File

@ -27,14 +27,14 @@
#define GRIM_MODEL_H
#include "common/memstream.h"
#include "engines/grim/resource.h"
#include "engines/grim/object.h"
#include "graphics/matrix4.h"
namespace Grim {
class TextSplitter;
class Material;
class CMap;
class Model : public Object {
public:
@ -49,7 +49,7 @@ public:
~Model();
Common::String _fname;
CMapPtr _cmap;
ObjectPtr<CMap> _cmap;
struct Geoset;
struct Mesh;
@ -139,7 +139,7 @@ public:
int _numMaterials;
char (*_materialNames)[32];
MaterialPtr *_materials;
ObjectPtr<Material> *_materials;
Graphics::Vector3d _insertOffset;
int _numGeosets;
Geoset *_geosets;

View File

@ -41,6 +41,7 @@ MODULE_OBJS := \
actor.o \
bitmap.o \
costume.o \
colormap.o \
detection.o \
font.o \
gfx_base.o \

View File

@ -85,8 +85,9 @@ public:
ObjectPtr(T *obj) :
_obj(obj) {
if (obj) {
_obj->reference();
addPointer(obj);
Object *o = (Object *)_obj;
o->reference();
addPointer(o);
}
}
ObjectPtr(const ObjectPtr<T> &ptr) : Pointer() {
@ -95,8 +96,9 @@ public:
}
~ObjectPtr() {
if (_obj) {
rmPointer(_obj);
_obj->dereference();
Object *o = (Object *)_obj;
rmPointer(o);
o->dereference();
}
}

View File

@ -28,6 +28,8 @@
#include "engines/grim/lua.h"
#include "engines/grim/grim.h"
#include "engines/grim/colormap.h"
#include "engines/grim/resource.h"
#include "engines/grim/bitmap.h"
namespace Grim {
@ -55,6 +57,29 @@ ObjectState::~ObjectState() {
delete _zbitmap;
}
const char *ObjectState::getBitmapFilename() const {
return _bitmap->getFilename();
}
void ObjectState::setNumber(int val) {
if (val) {
assert(_bitmap);
_bitmap->setNumber(val);
if (_zbitmap)
_zbitmap->setNumber(val);
}
_visibility = val != 0;
}
void ObjectState::draw() {
if (!_visibility)
return;
assert(_bitmap);
_bitmap->draw();
if (_zbitmap)
_zbitmap->draw();
}
void ObjectState::saveState(SaveGame *savedState) const {
savedState->writeLESint32(_visibility);
savedState->writeLEUint32(_setupID);

View File

@ -26,12 +26,12 @@
#ifndef GRIM_OSTATE_H
#define GRIM_OSTATE_H
#include "engines/grim/bitmap.h"
#include "engines/grim/object.h"
namespace Grim {
class SaveGame;
class Bitmap;
class ObjectState : public Object {
public:
@ -53,28 +53,10 @@ public:
Position getPos() const { return _pos; }
void setPos(Position position) { _pos = position; }
const char *getBitmapFilename() const {
return _bitmap->getFilename();
}
const char *getBitmapFilename() const;
void setNumber(int val) {
if (val) {
assert(_bitmap);
_bitmap->setNumber(val);
if (_zbitmap)
_zbitmap->setNumber(val);
}
_visibility = val != 0;
}
void draw() {
if (!_visibility)
return;
assert(_bitmap);
_bitmap->draw();
if (_zbitmap)
_zbitmap->draw();
}
void setNumber(int val);
void draw();
private:

View File

@ -29,6 +29,7 @@
#include "engines/grim/lua.h"
#include "engines/grim/colormap.h"
#include "engines/grim/grim.h"
#include "engines/grim/bitmap.h"
namespace Grim {
@ -42,7 +43,7 @@ PrimitiveObject::PrimitiveObject() :
PrimitiveObject::~PrimitiveObject() {
if (_bitmap && _type == 2)
delete _bitmap.object();
delete _bitmap;
}
void PrimitiveObject::saveState(SaveGame *savedState) const {
@ -127,7 +128,7 @@ void PrimitiveObject::draw() {
if (_type == RECTANGLE)
g_driver->drawRectangle(this);
else if (_type == BITMAP)
g_driver->drawBitmap(_bitmap.object());
g_driver->drawBitmap(_bitmap);
else if (_type == LINE)
g_driver->drawLine(this);
else if (_type == POLYGON)

View File

@ -28,11 +28,10 @@
#include "common/rect.h"
#include "engines/grim/color.h"
namespace Grim {
class SaveGame;
class Bitmap;
class PrimitiveObject : public Object {
public:
@ -60,7 +59,7 @@ public:
bool isFilled() { return _filled; }
void draw();
bool isBitmap() { return _type == BITMAP; }
Bitmap *getBitmapHandle() { assert(_bitmap); return _bitmap.object(); }
Bitmap *getBitmapHandle() { assert(_bitmap); return _bitmap; }
void saveState(SaveGame *state) const;
bool restoreState(SaveGame *state);
@ -69,7 +68,7 @@ private:
Color *_color;
bool _filled;
int _type;
BitmapPtr _bitmap;
Bitmap *_bitmap;
friend class GrimEngine;
};

View File

@ -32,7 +32,9 @@
#include "engines/grim/lipsync.h"
#include "engines/grim/savegame.h"
#include "engines/grim/actor.h"
#include "engines/grim/lab.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/font.h"
namespace Grim {

View File

@ -27,8 +27,8 @@
#define GRIM_RESOURCE_H
#include "common/archive.h"
#include "common/file.h"
#include "engines/grim/lab.h"
#include "engines/grim/object.h"
namespace Grim {
@ -43,6 +43,9 @@ class Model;
class LipSync;
class TrackedObject;
class SaveGame;
class Block;
class LuaFile;
class Lab;
typedef ObjectPtr<Material> MaterialPtr;
typedef ObjectPtr<Bitmap> BitmapPtr;

View File

@ -33,6 +33,8 @@
#include "engines/grim/grim.h"
#include "engines/grim/savegame.h"
#include "engines/grim/lua.h"
#include "engines/grim/resource.h"
#include "engines/grim/bitmap.h"
#include "engines/grim/imuse/imuse.h"
@ -83,7 +85,7 @@ void Scene::loadText(TextSplitter &ts){
ts.expectString("section: colormaps");
ts.scanString(" numcolormaps %d", 1, &_numCmaps);
_cmaps = new CMapPtr[_numCmaps];
_cmaps = new ObjectPtr<CMap>[_numCmaps];
char cmap_name[256];
for (int i = 0; i < _numCmaps; i++) {
ts.scanString(" colormap %256s", 1, cmap_name);

View File

@ -36,6 +36,7 @@ namespace Common {
namespace Grim {
class SaveGame;
class CMap;
class Scene {
public:
@ -130,7 +131,7 @@ private:
Common::String _name;
int _numCmaps;
CMapPtr *_cmaps;
ObjectPtr<CMap> *_cmaps;
int _numSetups, _numLights, _numSectors, _numObjectStates;
bool _enableLights;
Sector **_sectors;

View File

@ -43,6 +43,8 @@
#include "engines/grim/grim.h"
#include "engines/grim/colormap.h"
#include "engines/grim/resource.h"
#include "engines/grim/savegame.h"
namespace Grim {

View File

@ -28,6 +28,7 @@
#include "engines/grim/savegame.h"
#include "engines/grim/lua.h"
#include "engines/grim/colormap.h"
#include "engines/grim/font.h"
namespace Grim {
@ -301,6 +302,20 @@ void TextObject::createBitmap() {
_created = true;
}
void TextObject::subBaseOffsetY() {
if (_font)
_y -= _font->getBaseOffsetY();
else
_y -= 5;
}
int TextObject::getBaseOffsetY() {
if (_font)
return _font->getBaseOffsetY();
else
return 5;
}
void TextObject::destroyBitmap() {
_created = false;
if (_textObjectHandle) {

View File

@ -26,12 +26,12 @@
#ifndef GRIM_TEXTOBJECT_H
#define GRIM_TEXTOBJECT_H
#include "engines/grim/font.h"
#include "engines/grim/gfx_base.h"
namespace Grim {
class SaveGame;
class Font;
struct TextObjectDefaults {
Color *fgColor;
@ -55,18 +55,8 @@ public:
void setText(const char *text);
void setX(int x) { _x = x; }
void setY(int y) { _y = y; }
void subBaseOffsetY() {
if (_font)
_y -= _font->getBaseOffsetY();
else
_y -= 5;
}
int getBaseOffsetY() {
if (_font)
return _font->getBaseOffsetY();
else
return 5;
}
void subBaseOffsetY();
int getBaseOffsetY();
void setWidth(int width) { _width = width; }
void setHeight(int height) { _height = height; }
void setFGColor(Color *fgColor) { _fgColor = fgColor; }