Skip to content

Commit

Permalink
TONY: Move code from .h to .cpp files
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Sep 2, 2012
1 parent 1f41e55 commit c737e64
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 145 deletions.
44 changes: 42 additions & 2 deletions engines/tony/font.cpp
Expand Up @@ -188,6 +188,17 @@ void RMFontColor::setBaseColor(byte r1, byte g1, byte b1) {
_letter[i].loadPaletteWA(pal);
}

/***************************************************************************\
* RMFontWithTables Methods
\****************************************************************************/
int RMFontWithTables::convertToLetter(byte nChar) {
return _cTable[nChar];
}

int RMFontWithTables::letterLength(int nChar, int nNext) {
return (nChar != -1 ? _lTable[(byte)nChar] + _l2Table[(byte)nChar][(byte)nNext] : _lDefault);
}

/***************************************************************************\
* RMFontDialog Methods
\****************************************************************************/
Expand Down Expand Up @@ -359,7 +370,6 @@ RMText::RMText() {
}

RMText::~RMText() {

}

void RMText::unload() {
Expand Down Expand Up @@ -571,6 +581,23 @@ void RMText::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) {
CORO_END_CODE;
}

/**
* Set the alignment type
*/
void RMText::setAlignType(HorAlign aHor, VerAlign aVer) {
_aHorType = aHor;
_aVerType = aVer;
}

/**
* Set the base color
*/
void RMText::setColor(byte r, byte g, byte b) {
_textR = r;
_textG = g;
_textB = b;
}

/****************************************************************************\
* RMTextDialog Methods
\****************************************************************************/
Expand Down Expand Up @@ -751,6 +778,13 @@ void RMTextDialog::setInput(RMInput *input) {
_input = input;
}

/**
* Set the position
*/
void RMTextDialog::setPosition(const RMPoint &pt) {
_dst = pt;
}

/****************************************************************************\
* RMTextDialogScrolling Methods
\****************************************************************************/
Expand Down Expand Up @@ -801,7 +835,6 @@ RMTextItemName::RMTextItemName() : RMText() {
}

RMTextItemName::~RMTextItemName() {

}

void RMTextItemName::doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv) {
Expand Down Expand Up @@ -886,6 +919,13 @@ bool RMTextItemName::isItemSelected() {
return _item != NULL;
}

void RMTextItemName::setMouseCoord(const RMPoint &m) {
_mpos = m;
}

void RMTextItemName::removeThis(CORO_PARAM, bool &result) {
result = true;
}

/****************************************************************************\
* RMDialogChoice Methods
Expand Down
31 changes: 7 additions & 24 deletions engines/tony/font.h
Expand Up @@ -126,12 +126,8 @@ class RMFontWithTables : public virtual RMFont {

protected:
// Overloaded methods
int convertToLetter(byte nChar) {
return _cTable[nChar];
}
int letterLength(int nChar, int nNext = 0) {
return (nChar != -1 ? _lTable[(byte)nChar] + _l2Table[(byte)nChar][(byte)nNext] : _lDefault);
}
int convertToLetter(byte nChar);
int letterLength(int nChar, int nNext = 0);

public:
int letterHeight() {
Expand Down Expand Up @@ -206,10 +202,7 @@ class RMText : public RMGfxWoodyBuffer {
static void unload();

// Set the alignment type
void setAlignType(HorAlign aHor, VerAlign aVer) {
_aHorType = aHor;
_aVerType = aVer;
}
void setAlignType(HorAlign aHor, VerAlign aVer);

// Sets the maximum length of a line in pixels (used to format the text)
void setMaxLineLength(int max);
Expand All @@ -225,11 +218,7 @@ class RMText : public RMGfxWoodyBuffer {
virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);

// Set the base color
void setColor(byte r, byte g, byte b) {
_textR = r;
_textG = g;
_textB = b;
}
void setColor(byte r, byte g, byte b);
};

/**
Expand Down Expand Up @@ -269,9 +258,7 @@ class RMTextDialog : public RMText {
virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);

// Set the position
void setPosition(const RMPoint &pt) {
_dst = pt;
}
void setPosition(const RMPoint &pt);

// Waiting
void waitForEndDisplay(CORO_PARAM);
Expand Down Expand Up @@ -320,9 +307,7 @@ class RMTextItemName : protected RMText {
RMTextItemName();
virtual ~RMTextItemName();

void setMouseCoord(const RMPoint &m) {
_mpos = m;
}
void setMouseCoord(const RMPoint &m);

void doFrame(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMLocation &loc, RMPointer &ptr, RMInventory &inv);
virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
Expand All @@ -331,9 +316,7 @@ class RMTextItemName : protected RMText {
RMItem *getSelectedItem();
bool isItemSelected();

virtual void removeThis(CORO_PARAM, bool &result) {
result = true;
}
virtual void removeThis(CORO_PARAM, bool &result);
};


Expand Down
12 changes: 12 additions & 0 deletions engines/tony/game.cpp
Expand Up @@ -128,6 +128,14 @@ void RMOptionButton::addToList(RMGfxTargetBuffer &bigBuf) {
bigBuf.addPrim(new RMGfxPrimitive(this, _rect));
}

bool RMOptionButton::isActive() {
return _bActive;
}

void RMOptionButton::setActiveState(bool bState) {
_bActive = bState;
}

/****************************************************************************\
* RMOptionSlide Methods
\****************************************************************************/
Expand Down Expand Up @@ -253,6 +261,10 @@ void RMOptionSlide::addToList(RMGfxTargetBuffer &bigBuf) {
bigBuf.addPrim(new RMGfxPrimitive(this));
}

int RMOptionSlide::getValue() {
return _nValue;
}

/****************************************************************************\
* RMOptionScreen Methods
\****************************************************************************/
Expand Down
12 changes: 3 additions & 9 deletions engines/tony/game.h
Expand Up @@ -189,12 +189,8 @@ class RMOptionButton: public RMGfxTaskSetPrior {
bool doFrame(const RMPoint &mousePos, bool bLeftClick, bool bRightClick);
virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
void addToList(RMGfxTargetBuffer &bigBuf);
bool isActive() {
return _bActive;
}
void setActiveState(bool bState) {
_bActive = bState;
}
bool isActive();
void setActiveState(bool bState);
};

class RMOptionSlide : public RMGfxTaskSetPrior {
Expand All @@ -219,9 +215,7 @@ class RMOptionSlide : public RMGfxTaskSetPrior {
virtual void draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim);
void addToList(RMGfxTargetBuffer &bigBuf);

int getValue() {
return _nValue;
}
int getValue();
};

class RMOptionScreen : public RMGfxWoodyBuffer {
Expand Down
44 changes: 43 additions & 1 deletion engines/tony/gfxcore.cpp
Expand Up @@ -49,6 +49,17 @@ void RMGfxTask::removeThis(CORO_PARAM, bool &result) {
result = true;
}

/**
* Registration
*/
void RMGfxTask::Register() {
_nInList++;
}

void RMGfxTask::Unregister() {
_nInList--;
assert(_nInList >= 0);
}

/****************************************************************************\
* RMGfxTaskSetPrior Methods
Expand Down Expand Up @@ -192,7 +203,6 @@ bool RMGfxSourceBuffer::clip2D(int &x1, int &y1, int &u, int &v, int &width, int
return (width > 1 && height > 1);
}


/**
* Initializes a surface by resource Id
*
Expand All @@ -204,6 +214,10 @@ int RMGfxSourceBuffer::init(uint32 resID, int dimx, int dimy, bool bLoadPalette)
return init(RMRes(resID), dimx, dimy, bLoadPalette);
}

void RMGfxSourceBuffer::offsetY(int nLines) {
RMGfxBuffer::offsetY(nLines, getBpp());
}

/****************************************************************************\
* RMGfxWoodyBuffer Methods
\****************************************************************************/
Expand Down Expand Up @@ -440,6 +454,34 @@ void RMGfxTargetBuffer::freeBWPrecalcTable() {
_precalcTable = NULL;
}

RMGfxTargetBuffer::operator byte *() {
return _buf;
}

RMGfxTargetBuffer::operator void *() {
return (void *)_buf;
}

RMGfxTargetBuffer::operator uint16 *() {
// FIXME: This may not be endian safe
return (uint16 *)_buf;
}

/**
* Offseting buffer
*/
void RMGfxTargetBuffer::offsetY(int nLines) {
RMGfxBuffer::offsetY(nLines, 16);
}

void RMGfxTargetBuffer::setTrackDirtyRects(bool v) {
_trackDirtyRects = v;
}

bool RMGfxTargetBuffer::getTrackDirtyRects() const {
return _trackDirtyRects;
}

/****************************************************************************\
* RMGfxSourceBufferPal Methods
\****************************************************************************/
Expand Down
38 changes: 9 additions & 29 deletions engines/tony/gfxcore.h
Expand Up @@ -145,13 +145,8 @@ class RMGfxTask {
virtual void removeThis(CORO_PARAM, bool &result);

// Registration
virtual void Register() {
_nInList++;
}
virtual void Unregister() {
_nInList--;
assert(_nInList >= 0);
}
virtual void Register();
virtual void Unregister();
};


Expand Down Expand Up @@ -209,9 +204,7 @@ class RMGfxSourceBuffer : public virtual RMGfxBuffer, public RMGfxTaskSetPrior {
protected:
virtual void prepareImage();
bool clip2D(int &x1, int &y1, int &u, int &v, int &width, int &height, bool bUseSrc, RMGfxTargetBuffer *buf);
void offsetY(int nLines) {
RMGfxBuffer::offsetY(nLines, getBpp());
}
void offsetY(int nLines);

public:
virtual int getBpp() = 0;
Expand Down Expand Up @@ -490,32 +483,19 @@ class RMGfxTargetBuffer : public virtual RMGfxBuffer {
void drawOT(CORO_PARAM);
void addPrim(RMGfxPrimitive *prim); // The pointer must be delted

operator byte *() {
return _buf;
}
operator void *() {
return (void *)_buf;
}
operator uint16 *() {
// FIXME: This may not be endian safe
return (uint16 *)_buf;
}
operator byte *();
operator void *();
operator uint16 *();

// Offseting buffer
void offsetY(int nLines) {
RMGfxBuffer::offsetY(nLines, 16);
}
void offsetY(int nLines);

// Dirty rect methods
void addDirtyRect(const Common::Rect &r);
Common::List<Common::Rect> &getDirtyRects();
void clearDirtyRects();
void setTrackDirtyRects(bool v) {
_trackDirtyRects = v;
}
bool getTrackDirtyRects() const {
return _trackDirtyRects;
}
void setTrackDirtyRects(bool v);
bool getTrackDirtyRects() const;
};


Expand Down
15 changes: 15 additions & 0 deletions engines/tony/inventory.cpp
Expand Up @@ -736,6 +736,21 @@ int RMInventory::loadState(byte *state) {
return getSaveStateSize();
}

RMInventory &RMInventory::operator+=(RMItem *item) {
addItem(item->mpalCode());
return *this;
}

RMInventory &RMInventory::operator+=(RMItem &item) {
addItem(item.mpalCode());
return *this;
}

RMInventory &RMInventory::operator+=(int code) {
addItem(code);
return *this;
}

/****************************************************************************\
* RMInterface methods
\****************************************************************************/
Expand Down
15 changes: 3 additions & 12 deletions engines/tony/inventory.h
Expand Up @@ -146,18 +146,9 @@ class RMInventory : public RMGfxWoodyBuffer {
* Add an item to the inventory
*/
void addItem(int code);
RMInventory &operator+=(RMItem *item) {
addItem(item->mpalCode());
return *this;
}
RMInventory &operator+=(RMItem &item) {
addItem(item.mpalCode());
return *this;
}
RMInventory &operator+=(int code) {
addItem(code);
return *this;
}
RMInventory &operator+=(RMItem *item);
RMInventory &operator+=(RMItem &item);
RMInventory &operator+=(int code);

/**
* Removes an item
Expand Down

0 comments on commit c737e64

Please sign in to comment.