Remove most of default parameter values.

Also, add comments to the last commit.

svn-id: r45511
This commit is contained in:
Robert Špalek 2009-10-30 01:41:57 +00:00
parent a20e42efb9
commit c778efaca5
12 changed files with 39 additions and 36 deletions

View File

@ -127,7 +127,7 @@ void Animation::drawFrame(Surface *surface) {
const Drawable *frame = _frames[_currentFrame];
if (_id == kOverlayImage) {
frame->draw(surface, false);
frame->draw(surface, false, 0, 0);
} else {
// Draw frame
frame->drawReScaled(surface, false, _displacement);

View File

@ -160,9 +160,9 @@ public:
AnimationManager(DraciEngine *vm) : _vm(vm), _lastIndex(-1) {}
~AnimationManager() { deleteAll(); }
Animation *addAnimation(int id, uint z, bool playing = false);
Animation *addText(int id, bool playing = false);
Animation *addItem(int id, bool playing = false);
Animation *addAnimation(int id, uint z, bool playing);
Animation *addText(int id, bool playing);
Animation *addItem(int id, bool playing);
void addOverlay(Drawable *overlay, uint z);
void play(int id);

View File

@ -66,13 +66,13 @@ public:
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, int with_colour,
int spacing, bool markDirty = true) const;
int spacing, bool markDirty) const;
void drawString(Surface *dst, const Common::String &str,
int x, int y, int with_colour, int spacing, bool markDirty = true) const;
int x, int y, int with_colour, int spacing, bool markDirty) const;
uint getStringWidth(const Common::String &str, int spacing = 0) const;
uint getStringWidth(const Common::String &str, int spacing) const;
uint getStringHeight(const Common::String &str) const;
uint getLineWidth(const Common::String &str, uint startIndex, int spacing = 0) const;
uint getLineWidth(const Common::String &str, uint startIndex, int spacing) const;
private:
uint8 _fontHeight;

View File

@ -186,12 +186,12 @@ void Game::init() {
// Initialize animation for object / room titles
Animation *titleAnim = _vm->_anims->addText(kTitleText, true);
Text *title = new Text("", _vm->_smallFont, kTitleColour, 0, 0);
Text *title = new Text("", _vm->_smallFont, kTitleColour, 0, 0, 0);
titleAnim->addFrame(title, NULL);
// Initialize animation for speech text
Animation *speechAnim = _vm->_anims->addText(kSpeechText, true);
Text *speech = new Text("", _vm->_bigFont, kFontColour1, 0, 0);
Text *speech = new Text("", _vm->_bigFont, kFontColour1, 0, 0, 0);
speechAnim->addFrame(speech, NULL);
// Initialize inventory animation
@ -204,7 +204,7 @@ void Game::init() {
for (uint i = 0; i < kDialogueLines; ++i) {
_dialogueAnims[i] = _vm->_anims->addText(kDialogueLinesID - i, true);
Text *dialogueLine = new Text("", _vm->_smallFont, kLineInactiveColour, 0, 0);
Text *dialogueLine = new Text("", _vm->_smallFont, kLineInactiveColour, 0, 0, 0);
_dialogueAnims[i]->addFrame(dialogueLine, NULL);
_dialogueAnims[i]->setZ(254);
@ -503,7 +503,7 @@ void Game::updateCursor() {
if (_currentItem == kNoItem) {
_vm->_mouse->setCursorType(kNormalCursor);
} else {
_vm->_mouse->loadItemCursor(_currentItem);
_vm->_mouse->loadItemCursor(_currentItem, false);
}
}
@ -561,7 +561,7 @@ void Game::updateCursor() {
if (_currentItem == kNoItem) {
_vm->_mouse->setCursorType(kNormalCursor);
} else {
_vm->_mouse->loadItemCursor(_currentItem);
_vm->_mouse->loadItemCursor(_currentItem, false);
}
}
}
@ -667,7 +667,7 @@ void Game::putItem(int itemID, int position) {
const int anim_id = kInventoryItemsID - itemID;
Animation *anim = _vm->_anims->getAnimation(anim_id);
if (!anim) {
anim = _vm->_anims->addItem(anim_id);
anim = _vm->_anims->addItem(anim_id, false);
const BAFile *img = _vm->_itemImagesArchive->getFile(2 * itemID);
Sprite *sp = new Sprite(img->_data, img->_length, 0, 0, true);
anim->addFrame(sp, NULL);
@ -982,7 +982,7 @@ void Game::walkHero(int x, int y, SightDirection dir) {
return;
Surface *surface = _vm->_screen->getSurface();
_hero = _currentRoom._walkingMap.findNearestWalkable(x, y, surface->getRect());
_hero = _currentRoom._walkingMap.findNearestWalkable(x, y, surface->getDimensions());
debugC(3, kDraciLogicDebugLevel, "Walk to x: %d y: %d", _hero.x, _hero.y);
// FIXME: Need to add proper walking (this only warps the dragon to position)

View File

@ -220,7 +220,7 @@ public:
int loadAnimation(uint animNum, uint z);
void loadOverlays();
void loadObject(uint numObj);
void loadWalkingMap(int mapID);
void loadWalkingMap(int mapID); // <0 means the room's default walking map
void loadItem(int itemID);
uint getNumObjects() const;

View File

@ -58,7 +58,7 @@ public:
void setPosition(uint16 x, uint16 y);
CursorType getCursorType() const { return _cursorType; }
void setCursorType(CursorType cur);
void loadItemCursor(int itemID, bool highlighted = false);
void loadItemCursor(int itemID, bool highlighted);
bool lButtonPressed() const { return _lButton; }
bool rButtonPressed() const { return _rButton; }
void lButtonSet(bool state) { _lButton = state; }

View File

@ -573,7 +573,7 @@ void Script::icoStat(Common::Queue<int> &params) {
if (_vm->_game->getItemStatus(itemID) == 1) {
if (itemID != kNoItem) {
Animation *itemAnim = _vm->_anims->addItem(kInventoryItemsID - itemID);
Animation *itemAnim = _vm->_anims->addItem(kInventoryItemsID - itemID, false);
const BAFile *f = _vm->_itemImagesArchive->getFile(2 * itemID);
Sprite *sp = new Sprite(f->_data, f->_length, 0, 0, true);
itemAnim->addFrame(sp, NULL);
@ -581,7 +581,7 @@ void Script::icoStat(Common::Queue<int> &params) {
_vm->_game->setCurrentItem(itemID);
_vm->_mouse->loadItemCursor(itemID);
_vm->_mouse->loadItemCursor(itemID, false);
// TODO: This is probably not needed but I'm leaving it to be sure for now
// The original engine needed to turn off the mouse temporarily when changing
@ -718,7 +718,7 @@ void Script::talk(Common::Queue<int> &params) {
? NULL : _vm->_dubbingArchive->getSample(sentenceID, 0);
// Set the string and text colour
surface->markDirtyRect(speechFrame->getRect());
surface->markDirtyRect(speechFrame->getRect(kNoDisplacement));
if (_vm->_sound->showSubtitles() || !sample) {
speechFrame->setText(Common::String((const char *)f->_data+1, f->_length-1));
} else {
@ -780,7 +780,7 @@ void Script::talk(Common::Queue<int> &params) {
_vm->_game->loop();
// Delete the text
_vm->_screen->getSurface()->markDirtyRect(speechFrame->getRect());
_vm->_screen->getSurface()->markDirtyRect(speechFrame->getRect(kNoDisplacement));
speechFrame->setText("");
// Stop the playing sample and deallocate it. Stopping should only be

View File

@ -332,7 +332,7 @@ uint Text::getLength() const {
}
void Text::draw(Surface *surface, bool markDirty, int relX, int relY) const {
_font->drawString(surface, _text, _x + relX, _y + relY, _colour, _spacing);
_font->drawString(surface, _text, _x + relX, _y + relY, _colour, _spacing, true);
}
// TODO: Handle scaled parameter properly by implementing Text scaling

View File

@ -44,8 +44,8 @@ extern const Displacement kNoDisplacement;
class Drawable {
public:
virtual void draw(Surface *surface, bool markDirty, int relX=0, int relY=0) const = 0;
virtual void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement = kNoDisplacement) const = 0;
virtual void draw(Surface *surface, bool markDirty, int relX, int relY) const = 0;
virtual void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement) const = 0;
virtual ~Drawable() {};
@ -69,7 +69,7 @@ public:
void setDelay(int delay) { _delay = delay; }
int getDelay() const { return _delay; }
virtual Common::Rect getRect(const Displacement &displacement = kNoDisplacement) const = 0;
virtual Common::Rect getRect(const Displacement &displacement) const = 0;
virtual DrawableType getType() const = 0;
@ -106,16 +106,16 @@ public:
~Sprite();
void draw(Surface *surface, bool markDirty, int relX=0, int relY=0) const;
void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement = kNoDisplacement) const;
void draw(Surface *surface, bool markDirty, int relX, int relY) const;
void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement) const;
void setMirrorOn();
void setMirrorOff();
Common::Rect getRect(const Displacement &displacement = kNoDisplacement) const;
Common::Rect getRect(const Displacement &displacement) const;
const byte *getBuffer() const { return _data; }
int getPixel(int x, int y, const Displacement &displacement = kNoDisplacement) const;
int getPixel(int x, int y, const Displacement &displacement) const;
DrawableType getType() const { return kDrawableSprite; }
@ -128,7 +128,7 @@ class Text : public Drawable {
public:
Text(const Common::String &str, const Font *font, byte fontColour,
int x, int y, uint spacing = 0);
int x, int y, uint spacing);
~Text() {};
void setText(const Common::String &str);
@ -138,13 +138,13 @@ public:
uint getLength() const;
void draw(Surface *surface, bool markDirty, int relX=0, int relY=0) const;
void draw(Surface *surface, bool markDirty, int relX, int relY) const;
// TODO: drawReScaled just calls draw so Text can be accessed through a Drawable pointer.
// Handle scaling text sometimes (not essential).
void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement = kNoDisplacement) const { draw(surface, markDirty, displacement.relX, displacement.relY); }
Common::Rect getRect(const Displacement &displacement = kNoDisplacement) const;
void drawReScaled(Surface *surface, bool markDirty, const Displacement &displacement) const { draw(surface, markDirty, displacement.relX, displacement.relY); }
Common::Rect getRect(const Displacement &displacement) const;
DrawableType getType() const { return kDrawableText; }
private:

View File

@ -168,7 +168,7 @@ uint Surface::putAboveY(int y, int height) const {
/**
* @brief Returns a Common::Rect corresponding to the surface.
*/
Common::Rect Surface::getRect() const {
Common::Rect Surface::getDimensions() const {
return Common::Rect(w, h);
}

View File

@ -47,7 +47,7 @@ public:
void fill(uint colour);
uint putAboveY(int y, int height) const;
uint centerOnX(int x, int width) const;
Common::Rect getRect() const;
Common::Rect getDimensions() const;
private:
/** The current transparent colour of the surface. See getTransparentColour() and

View File

@ -32,7 +32,8 @@ namespace Draci {
class WalkingMap {
public:
WalkingMap() : _realWidth(0), _realHeight(0), _mapWidth(0), _mapHeight(0), _byteWidth(0), _data(NULL) { }
WalkingMap() : _realWidth(0), _realHeight(0), _deltaX(1), _deltaY(1),
_mapWidth(0), _mapHeight(0), _byteWidth(0), _data(NULL) { }
void load(const byte *data, uint length);
bool isWalkable(int x, int y) const;
@ -43,6 +44,8 @@ private:
int _deltaX, _deltaY;
int _mapWidth, _mapHeight;
int _byteWidth;
// We don't own the pointer. It points to the BArchive cache for this room.
const byte *_data;
};