DREAMWEB: Clean up checkCoords

This commit is contained in:
Willem Jan Palenstijn 2011-12-28 16:55:03 +01:00
parent 00f230975c
commit ea6546ae25
8 changed files with 32 additions and 35 deletions

@ -905,21 +905,7 @@ public:
void setAllChanges();
void restoreAll();
void redrawMainScrn();
template <class T>
void checkCoords(const RectWithCallback<T> *rectWithCallbacks) {
if (_newLocation != 0xff)
return;
const RectWithCallback<T> *r;
for (r = rectWithCallbacks; r->_xMin != 0xffff; ++r) {
if (r->contains(_mouseX, _mouseY)) {
(((T *)this)->*(r->_callback))();
return;
}
}
}
void checkCoords(const RectWithCallback *rectWithCallbacks);
void newGame();
void deleteTaken();
void autoAppear();

@ -28,7 +28,7 @@ const uint16 kKeypadx = 36+112;
const uint16 kKeypady = 72;
void DreamWebEngine::enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 digit3) {
RectWithCallback<DreamWebEngine> keypadList[] = {
RectWithCallback keypadList[] = {
{ kKeypadx+9,kKeypadx+30,kKeypady+9,kKeypady+22,&DreamWebEngine::buttonOne },
{ kKeypadx+31,kKeypadx+52,kKeypady+9,kKeypady+22,&DreamWebEngine::buttonTwo },
{ kKeypadx+53,kKeypadx+74,kKeypady+9,kKeypady+22,&DreamWebEngine::buttonThree },
@ -263,7 +263,7 @@ void DreamWebEngine::useMenu() {
dumpPointer();
dumpMenu();
dumpTextLine();
RectWithCallback<DreamWebEngine> menuList[] = {
RectWithCallback menuList[] = {
{ kMenux+54,kMenux+68,kMenuy+72,kMenuy+88,&DreamWebEngine::quitKey },
{ 0,320,0,200,&DreamWebEngine::blank },
{ 0xFFFF,0,0,0,0 }
@ -396,7 +396,7 @@ void DreamWebEngine::lastFolder() {
}
void DreamWebEngine::checkFolderCoords() {
RectWithCallback<DreamWebEngine> folderList[] = {
RectWithCallback folderList[] = {
{ 280,320,160,200, &DreamWebEngine::quitKey },
{ 143,300,6,194, &DreamWebEngine::nextFolder },
{ 0,143,6,194, &DreamWebEngine::lastFolder },
@ -525,7 +525,7 @@ void DreamWebEngine::enterSymbol() {
dumpPointer();
dumpTextLine();
dumpSymbol();
RectWithCallback<DreamWebEngine> symbolList[] = {
RectWithCallback symbolList[] = {
{ kSymbolx+40,kSymbolx+64,kSymboly+2,kSymboly+16,&DreamWebEngine::quitSymbol },
{ kSymbolx,kSymbolx+52,kSymboly+20,kSymboly+50,&DreamWebEngine::setTopLeft },
{ kSymbolx+52,kSymbolx+104,kSymboly+20,kSymboly+50,&DreamWebEngine::setTopRight },
@ -765,7 +765,7 @@ void DreamWebEngine::useDiary() {
delPointer();
_getBack = 0;
RectWithCallback<DreamWebEngine> diaryList[] = {
RectWithCallback diaryList[] = {
{ kDiaryx+94,kDiaryx+110,kDiaryy+97,kDiaryy+113,&DreamWebEngine::diaryKeyN },
{ kDiaryx+151,kDiaryx+167,kDiaryy+71,kDiaryy+87,&DreamWebEngine::diaryKeyP },
{ kDiaryx+176,kDiaryx+192,kDiaryy+108,kDiaryy+124,&DreamWebEngine::quitKey },

@ -72,7 +72,7 @@ void DreamWebEngine::selectLocation() {
if (_getBack == 1)
break;
RectWithCallback<DreamWebEngine> destList[] = {
RectWithCallback destList[] = {
{ 238,258,4,44,&DreamWebEngine::nextDest },
{ 104,124,4,44,&DreamWebEngine::lastDest },
{ 280,308,4,44,&DreamWebEngine::lookAtPlace },

@ -155,7 +155,7 @@ void DreamWebEngine::examineOb(bool examineAgain) {
switch (_invOpen) {
case 0: {
RectWithCallback<DreamWebEngine> examList[] = {
RectWithCallback examList[] = {
{ 273,320,157,198,&DreamWebEngine::getBackFromOb },
{ 260,300,0,44,&DreamWebEngine::useObject },
{ 210,254,0,44,&DreamWebEngine::selectOpenOb },
@ -169,7 +169,7 @@ void DreamWebEngine::examineOb(bool examineAgain) {
}
case 1: {
// Note: This table contains the non-constant _openChangeSize!
RectWithCallback<DreamWebEngine> invList1[] = {
RectWithCallback invList1[] = {
{ 273,320,157,198,&DreamWebEngine::getBackFromOb },
{ 255,294,0,24,&DreamWebEngine::dropObject },
{ kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamWebEngine::incRyanPage },
@ -182,7 +182,7 @@ void DreamWebEngine::examineOb(bool examineAgain) {
break;
}
default: {
RectWithCallback<DreamWebEngine> withList1[] = {
RectWithCallback withList1[] = {
{ 273,320,157,198,&DreamWebEngine::getBackFromOb },
{ kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamWebEngine::incRyanPage },
{ kInventx,kInventx+(5*kItempicsize), kInventy,kInventy+(2*kItempicsize),&DreamWebEngine::selectOb },

@ -142,7 +142,7 @@ void DreamWebEngine::doLoad(int savegameId) {
vSync();
dumpPointer();
dumpTextLine();
RectWithCallback<DreamWebEngine> loadlist[] = {
RectWithCallback loadlist[] = {
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamWebEngine::getBackToOps },
{ kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamWebEngine::actualLoad },
{ kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamWebEngine::selectSlot },
@ -236,7 +236,7 @@ void DreamWebEngine::saveGame() {
dumpPointer();
dumpTextLine();
RectWithCallback<DreamWebEngine> savelist[] = {
RectWithCallback savelist[] = {
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamWebEngine::getBackToOps },
{ kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamWebEngine::actualSave },
{ kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamWebEngine::selectSlot },
@ -327,7 +327,7 @@ void DreamWebEngine::doSaveLoad() {
showMainOps();
workToScreen();
RectWithCallback<DreamWebEngine> opsList[] = {
RectWithCallback opsList[] = {
{ kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamWebEngine::getBackFromOps },
{ kOpsx+10,kOpsx+77,kOpsy+10,kOpsy+59,&DreamWebEngine::DOSReturn },
{ kOpsx+128,kOpsx+190,kOpsy+16,kOpsy+100,&DreamWebEngine::discOps },
@ -427,7 +427,7 @@ void DreamWebEngine::discOps() {
workToScreenM();
_getBack = 0;
RectWithCallback<DreamWebEngine> discOpsList[] = {
RectWithCallback discOpsList[] = {
{ kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamWebEngine::loadGame },
{ kOpsx+10,kOpsx+79,kOpsy+10,kOpsy+59,&DreamWebEngine::saveGame },
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamWebEngine::getBackToOps },

@ -47,11 +47,10 @@ struct Sprite {
uint8 hidden;
};
template <class T = DreamWebEngine>
struct RectWithCallback {
uint16 _xMin, _xMax;
uint16 _yMin, _yMax;
void (T::*_callback)();
void (DreamWebEngine::*_callback)();
bool contains(uint16 x, uint16 y) const {
return (x >= _xMin) && (x < _xMax) && (y >= _yMin) && (y < _yMax);

@ -1803,7 +1803,7 @@ void DreamWebEngine::sortOutMap() {
void DreamWebEngine::mainScreen() {
_inMapArea = 0;
if (_vars._watchOn == 1) {
RectWithCallback<DreamWebEngine> mainList[] = {
RectWithCallback mainList[] = {
{ 44,70,32,46,&DreamWebEngine::look },
{ 0,50,0,180,&DreamWebEngine::inventory },
{ 226,244,10,26,&DreamWebEngine::zoomOnOff },
@ -1814,7 +1814,7 @@ void DreamWebEngine::mainScreen() {
};
checkCoords(mainList);
} else {
RectWithCallback<DreamWebEngine> mainList2[] = {
RectWithCallback mainList2[] = {
{ 44,70,32,46,&DreamWebEngine::look },
{ 0,50,0,180,&DreamWebEngine::inventory },
{ 226+48,244+48,10,26,&DreamWebEngine::zoomOnOff },
@ -2679,7 +2679,7 @@ void DreamWebEngine::decide() {
fadeScreenUp();
_getBack = 0;
RectWithCallback<DreamWebEngine> decideList[] = {
RectWithCallback decideList[] = {
{ kOpsx+69,kOpsx+124,kOpsy+30,kOpsy+76,&DreamWebEngine::newGame },
{ kOpsx+20,kOpsx+87,kOpsy+10,kOpsy+59,&DreamWebEngine::DOSReturn },
{ kOpsx+123,kOpsx+190,kOpsy+10,kOpsy+59,&DreamWebEngine::loadOld },
@ -3143,4 +3143,16 @@ void DreamWebEngine::purgeAnItem() {
}
}
void DreamWebEngine::checkCoords(const RectWithCallback *rectWithCallbacks) {
if (_newLocation != 0xff)
return;
const RectWithCallback *r;
for (r = rectWithCallbacks; r->_xMin != 0xffff; ++r) {
if (r->contains(_mouseX, _mouseY)) {
(this->*(r->_callback))();
return;
}
}
}
} // End of namespace DreamWeb

@ -40,7 +40,7 @@ void DreamWebEngine::talk() {
showPointer();
workToScreen();
RectWithCallback<DreamWebEngine> talkList[] = {
RectWithCallback talkList[] = {
{ 273,320,157,198,&DreamWebEngine::getBack1 },
{ 240,290,2,44,&DreamWebEngine::moreTalk },
{ 0,320,0,200,&DreamWebEngine::blank },
@ -201,7 +201,7 @@ void DreamWebEngine::doSomeTalk() {
bool DreamWebEngine::hangOnPQ() {
_getBack = 0;
RectWithCallback<DreamWebEngine> quitList[] = {
RectWithCallback quitList[] = {
{ 273,320,157,198,&DreamWebEngine::getBack1 },
{ 0,320,0,200,&DreamWebEngine::blank },
{ 0xFFFF,0,0,0,0 }