aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/animation.cpp2
-rw-r--r--engines/draci/animation.h2
-rw-r--r--engines/draci/font.cpp23
-rw-r--r--engines/draci/font.h11
-rw-r--r--engines/draci/game.h4
-rw-r--r--engines/draci/screen.cpp2
-rw-r--r--engines/draci/screen.h2
-rw-r--r--engines/draci/script.cpp4
-rw-r--r--engines/draci/script.h5
-rw-r--r--engines/draci/sprite.cpp8
-rw-r--r--engines/draci/sprite.h6
11 files changed, 26 insertions, 43 deletions
diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp
index 880191d90f..f4333c01de 100644
--- a/engines/draci/animation.cpp
+++ b/engines/draci/animation.cpp
@@ -553,7 +553,7 @@ void AnimationManager::deleteAll() {
_lastIndex = -1;
}
-int AnimationManager::getLastIndex() {
+int AnimationManager::getLastIndex() const {
return _lastIndex;
}
diff --git a/engines/draci/animation.h b/engines/draci/animation.h
index 83161cd639..d71da984cd 100644
--- a/engines/draci/animation.h
+++ b/engines/draci/animation.h
@@ -170,7 +170,7 @@ public:
Animation *getAnimation(int id);
- int getLastIndex();
+ int getLastIndex() const;
void deleteAfterIndex(int index);
int getTopAnimationID(int x, int y);
diff --git a/engines/draci/font.cpp b/engines/draci/font.cpp
index 093b8d9d17..ddba64ba43 100644
--- a/engines/draci/font.cpp
+++ b/engines/draci/font.cpp
@@ -41,8 +41,6 @@ Font::Font(const Common::String &filename) {
_charData = NULL;
loadFont(filename);
-
- _currentFontColour = kFontColour1;
}
Font::~Font() {
@@ -50,15 +48,6 @@ Font::~Font() {
}
/**
- * @brief Sets the varying font colour
- * @param colour The new font colour
- */
-
-void Font::setColour(uint8 colour) {
- _currentFontColour = colour;
-}
-
-/**
* @brief Loads fonts from a file
* @param path Path to font file
* @return true if the font was loaded successfully, false otherwise
@@ -132,7 +121,7 @@ uint8 Font::getCharWidth(uint8 chr) const {
* @param ty Vertical offset on the surface
*/
-void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty) const {
+void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) const {
assert(dst != NULL);
assert(tx >= 0);
assert(ty >= 0);
@@ -166,7 +155,7 @@ void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty) const {
switch (colour) {
case 254:
- colour = _currentFontColour;
+ colour = with_colour;
break;
case 253:
@@ -203,8 +192,8 @@ void Font::drawChar(Surface *dst, uint8 chr, int tx, int ty) const {
*/
void Font::drawString(Surface *dst, const byte *str, uint len,
- int x, int y, int spacing, bool markDirty) const {
- drawString(dst, Common::String((const char *)str, len), x, y, spacing, markDirty);
+ int x, int y, int with_colour, int spacing, bool markDirty) const {
+ drawString(dst, Common::String((const char *)str, len), x, y, with_colour, spacing, markDirty);
}
/**
@@ -218,7 +207,7 @@ void Font::drawString(Surface *dst, const byte *str, uint len,
*/
void Font::drawString(Surface *dst, const Common::String &str,
- int x, int y, int spacing, bool markDirty) const {
+ int x, int y, int with_colour, int spacing, bool markDirty) const {
assert(dst != NULL);
assert(x >= 0);
assert(y >= 0);
@@ -243,7 +232,7 @@ void Font::drawString(Surface *dst, const Common::String &str,
break;
}
- drawChar(dst, str[i], curx, cury);
+ drawChar(dst, str[i], curx, cury, with_colour);
curx += getCharWidth(str[i]) + spacing;
}
diff --git a/engines/draci/font.h b/engines/draci/font.h
index 5258108add..de2fe5d3da 100644
--- a/engines/draci/font.h
+++ b/engines/draci/font.h
@@ -61,19 +61,17 @@ public:
uint8 getFontHeight() const { return _fontHeight; };
uint8 getMaxCharWidth() const { return _maxCharWidth; };
uint8 getCharWidth(byte chr) const;
- void drawChar(Surface *dst, uint8 chr, int tx, int ty) const;
+ void drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_colour) const;
- void drawString(Surface *dst, const byte *str, uint len, int x, int y,
+ void drawString(Surface *dst, const byte *str, uint len, int x, int y, int with_colour,
int spacing, bool markDirty = true) const;
void drawString(Surface *dst, const Common::String &str,
- int x, int y, int spacing, bool markDirty = true) const;
+ int x, int y, int with_colour, int spacing, bool markDirty = true) const;
uint getStringWidth(const Common::String &str, int spacing = 0) const;
uint getStringHeight(const Common::String &str) const;
uint getLineWidth(const Common::String &str, uint startIndex, int spacing = 0) const;
- void setColour(uint8 colour);
-
private:
uint8 _fontHeight;
uint8 _maxCharWidth;
@@ -93,9 +91,6 @@ private:
*/
static const unsigned int kCharIndexOffset = 32;
- /** The varying font colour; initially set to kFontColour1 */
- uint8 _currentFontColour;
-
/** Internal function for freeing fonts when destructing/loading another */
void freeFont();
};
diff --git a/engines/draci/game.h b/engines/draci/game.h
index 8187438979..a3129fdaec 100644
--- a/engines/draci/game.h
+++ b/engines/draci/game.h
@@ -105,7 +105,7 @@ public:
_data = NULL;
}
- void load(byte *data, uint length) {
+ void load(const byte *data, uint length) {
Common::MemoryReadStream mapReader(data, length);
_realWidth = mapReader.readUint16LE();
@@ -128,7 +128,7 @@ private:
int _deltaX, _deltaY;
int _mapWidth, _mapHeight;
int _byteWidth;
- byte *_data;
+ const byte *_data;
};
struct GameObject {
diff --git a/engines/draci/screen.cpp b/engines/draci/screen.cpp
index 5d3c612978..95673ca1cb 100644
--- a/engines/draci/screen.cpp
+++ b/engines/draci/screen.cpp
@@ -143,7 +143,7 @@ void Screen::fillScreen(uint8 colour) {
* @param r Which rectangle to draw
* colour The colour of the rectangle
*/
-void Screen::drawRect(Common::Rect &r, uint8 colour) {
+void Screen::drawRect(Common::Rect r, uint8 colour) {
// Clip the rectangle to screen size
r.clip(_surface->w, _surface->h);
diff --git a/engines/draci/screen.h b/engines/draci/screen.h
index b9c3d1b4d2..a9f385d3c6 100644
--- a/engines/draci/screen.h
+++ b/engines/draci/screen.h
@@ -53,7 +53,7 @@ public:
void clearScreen();
void fillScreen(uint8 colour);
Surface *getSurface();
- void drawRect(Common::Rect &r, uint8 colour);
+ void drawRect(Common::Rect r, uint8 colour);
private:
Surface *_surface;
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 645bd136b6..7cac75b757 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -907,7 +907,7 @@ int Script::handleMathExpression(Common::MemoryReadStream &reader) const {
*
* Reference: the function equivalent to this one is called "Can()" in the original engine.
*/
-bool Script::testExpression(GPL2Program program, uint16 offset) const {
+bool Script::testExpression(const GPL2Program &program, uint16 offset) const {
// Initialize program reader
Common::MemoryReadStream reader(program._bytecode, program._length);
@@ -987,7 +987,7 @@ const GPL2Command *Script::findCommand(byte num, byte subnum) const {
* value comes from.
*/
-int Script::run(GPL2Program program, uint16 offset) {
+int Script::run(const GPL2Program &program, uint16 offset) {
int oldJump = _jump;
diff --git a/engines/draci/script.h b/engines/draci/script.h
index 2cbdff0f0e..4e94281b50 100644
--- a/engines/draci/script.h
+++ b/engines/draci/script.h
@@ -42,6 +42,7 @@ enum {
kNumCommands = 55
};
+// TODO(spalek): shouldn't modify params passed by reference. Either make it const or copy the parameter.
typedef void (Script::* GPLHandler)(Common::Queue<int> &);
typedef int (Script::* GPLOperatorHandler)(int, int) const;
typedef int (Script::* GPLFunctionHandler)(int) const;
@@ -88,8 +89,8 @@ class Script {
public:
Script(DraciEngine *vm) : _vm(vm), _jump(0) { setupCommandList(); };
- int run(GPL2Program program, uint16 offset);
- bool testExpression(GPL2Program, uint16 offset) const;
+ int run(const GPL2Program &program, uint16 offset);
+ bool testExpression(const GPL2Program &program, uint16 offset) const;
void endCurrentProgram();
private:
diff --git a/engines/draci/sprite.cpp b/engines/draci/sprite.cpp
index d256d9ffae..2028f7ab4b 100644
--- a/engines/draci/sprite.cpp
+++ b/engines/draci/sprite.cpp
@@ -302,7 +302,7 @@ Common::Rect Sprite::getRect(bool scaled) const {
return Common::Rect(_x, _y, _x + _width, _y + _height);
}
-Text::Text(const Common::String &str, Font *font, byte fontColour,
+Text::Text(const Common::String &str, const Font *font, byte fontColour,
int x, int y, uint spacing) {
_x = x;
_y = y;
@@ -357,9 +357,7 @@ uint Text::getLength() const {
}
void Text::draw(Surface *surface, bool markDirty) const {
- _font->setColour(_colour);
-
- _font->drawString(surface, _text, _x, _y, _spacing);
+ _font->drawString(surface, _text, _x, _y, _colour, _spacing);
}
// TODO: Handle scaled parameter properly by implementing Text scaling
@@ -367,7 +365,7 @@ Common::Rect Text::getRect(bool scaled) const {
return Common::Rect(_x, _y, _x + _width, _y + _height);
}
-void Text::setFont(Font *font) {
+void Text::setFont(const Font *font) {
_font = font;
_width = _font->getStringWidth(_text, _spacing);
diff --git a/engines/draci/sprite.h b/engines/draci/sprite.h
index e59149de42..0488043c7e 100644
--- a/engines/draci/sprite.h
+++ b/engines/draci/sprite.h
@@ -121,14 +121,14 @@ private:
class Text : public Drawable {
public:
- Text(const Common::String &str, Font *font, byte fontColour,
+ Text(const Common::String &str, const Font *font, byte fontColour,
int x, int y, uint spacing = 0);
~Text() {};
void setText(const Common::String &str);
void setColour(byte fontColour);
void setSpacing(uint spacing);
- void setFont(Font *font);
+ void setFont(const Font *font);
uint getLength() const;
@@ -147,7 +147,7 @@ private:
uint _length;
uint8 _colour;
uint _spacing;
- Font *_font;
+ const Font *_font;
};
} // End of namespace Draci