mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 12:48:16 +00:00
DREAMWEB: Turn RectWithCallback into template
Also moves checkCoords to DreamBase, adding a nasty cast to it. This is a temporary HACK, which allows moving functions that use checkCoords to DreamBase one at a time, instead of all at once (and at the same time as checkCoords). This can be undone once everything using checkCoords has been moved to DreamBase.
This commit is contained in:
parent
a4ffb8fe54
commit
cdc6bc421b
@ -457,6 +457,7 @@ public:
|
||||
void setAllChanges();
|
||||
void restoreAll();
|
||||
void redrawMainScrn();
|
||||
template <class T> void checkCoords(const RectWithCallback<T> *rectWithCallbacks);
|
||||
|
||||
// from use.cpp
|
||||
void placeFreeObject(uint8 index);
|
||||
|
@ -93,7 +93,7 @@ void DreamBase::addToPressList() {
|
||||
}
|
||||
|
||||
void DreamGenContext::enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 digit3) {
|
||||
RectWithCallback keypadList[] = {
|
||||
RectWithCallback<DreamGenContext> keypadList[] = {
|
||||
{ kKeypadx+9,kKeypadx+30,kKeypady+9,kKeypady+22,&DreamBase::buttonOne },
|
||||
{ kKeypadx+31,kKeypadx+52,kKeypady+9,kKeypady+22,&DreamBase::buttonTwo },
|
||||
{ kKeypadx+53,kKeypadx+74,kKeypady+9,kKeypady+22,&DreamBase::buttonThree },
|
||||
|
@ -170,7 +170,7 @@ void DreamGenContext::examineOb(bool examineAgain) {
|
||||
|
||||
switch (data.byte(kInvopen)) {
|
||||
case 0: {
|
||||
RectWithCallback examList[] = {
|
||||
RectWithCallback<DreamGenContext> examList[] = {
|
||||
{ 273,320,157,198,&DreamGenContext::getBackFromOb },
|
||||
{ 260,300,0,44,&DreamGenContext::useObject },
|
||||
{ 210,254,0,44,&DreamGenContext::selectOpenOb },
|
||||
@ -184,7 +184,7 @@ void DreamGenContext::examineOb(bool examineAgain) {
|
||||
}
|
||||
case 1: {
|
||||
// Note: This table contains the non-constant _openChangeSize!
|
||||
RectWithCallback invList1[] = {
|
||||
RectWithCallback<DreamGenContext> invList1[] = {
|
||||
{ 273,320,157,198,&DreamGenContext::getBackFromOb },
|
||||
{ 255,294,0,24,&DreamGenContext::dropObject },
|
||||
{ kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamGenContext::incRyanPage },
|
||||
@ -197,7 +197,7 @@ void DreamGenContext::examineOb(bool examineAgain) {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
RectWithCallback withList1[] = {
|
||||
RectWithCallback<DreamGenContext> withList1[] = {
|
||||
{ 273,320,157,198,&DreamGenContext::getBackFromOb },
|
||||
{ kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamGenContext::incRyanPage },
|
||||
{ kInventx,kInventx+(5*kItempicsize), kInventy,kInventy+(2*kItempicsize),&DreamGenContext::selectOb },
|
||||
|
@ -80,7 +80,7 @@ void DreamGenContext::doLoad(int savegameId) {
|
||||
vSync();
|
||||
dumpPointer();
|
||||
dumpTextLine();
|
||||
RectWithCallback loadlist[] = {
|
||||
RectWithCallback<DreamGenContext> loadlist[] = {
|
||||
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamBase::getBackToOps },
|
||||
{ kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamBase::actualLoad },
|
||||
{ kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamBase::selectSlot },
|
||||
@ -176,7 +176,7 @@ void DreamGenContext::saveGame() {
|
||||
dumpPointer();
|
||||
dumpTextLine();
|
||||
|
||||
RectWithCallback savelist[] = {
|
||||
RectWithCallback<DreamGenContext> savelist[] = {
|
||||
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamBase::getBackToOps },
|
||||
{ kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamBase::actualSave },
|
||||
{ kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamBase::selectSlot },
|
||||
@ -267,7 +267,7 @@ void DreamGenContext::doSaveLoad() {
|
||||
showMainOps();
|
||||
workToScreenCPP();
|
||||
|
||||
RectWithCallback opsList[] = {
|
||||
RectWithCallback<DreamGenContext> opsList[] = {
|
||||
{ kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamBase::getBackFromOps },
|
||||
{ kOpsx+10,kOpsx+77,kOpsy+10,kOpsy+59,&DreamBase::DOSReturn },
|
||||
{ kOpsx+128,kOpsx+190,kOpsy+16,kOpsy+100,&DreamGenContext::discOps },
|
||||
@ -367,7 +367,7 @@ void DreamGenContext::discOps() {
|
||||
workToScreenM();
|
||||
data.byte(kGetback) = 0;
|
||||
|
||||
RectWithCallback discOpsList[] = {
|
||||
RectWithCallback<DreamGenContext> discOpsList[] = {
|
||||
{ kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamGenContext::loadGame },
|
||||
{ kOpsx+10,kOpsx+79,kOpsy+10,kOpsy+59,&DreamGenContext::saveGame },
|
||||
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamBase::getBackToOps },
|
||||
|
@ -62,10 +62,11 @@ struct Sprite {
|
||||
|
||||
class DreamGenContext;
|
||||
|
||||
template <class T = DreamGenContext>
|
||||
struct RectWithCallback {
|
||||
uint16 _xMin, _xMax;
|
||||
uint16 _yMin, _yMax;
|
||||
void (DreamGenContext::*_callback)();
|
||||
void (T::*_callback)();
|
||||
|
||||
bool contains(uint16 x, uint16 y) const {
|
||||
return (x >= _xMin) && (x < _xMax) && (y >= _yMin) && (y < _yMax);
|
||||
|
@ -1566,14 +1566,15 @@ void DreamBase::dumpPointer() {
|
||||
multiDump(data.word(kOldpointerx), data.word(kOldpointery), data.byte(kPointerxs), data.byte(kPointerys));
|
||||
}
|
||||
|
||||
void DreamGenContext::checkCoords(const RectWithCallback *rectWithCallbacks) {
|
||||
template <class T>
|
||||
void DreamBase::checkCoords(const RectWithCallback<T> *rectWithCallbacks) {
|
||||
if (data.byte(kNewlocation) != 0xff)
|
||||
return;
|
||||
|
||||
const RectWithCallback *r;
|
||||
const RectWithCallback<T> *r;
|
||||
for (r = rectWithCallbacks; r->_xMin != 0xffff; ++r) {
|
||||
if (r->contains(data.word(kMousex), data.word(kMousey))) {
|
||||
(this->*(r->_callback))();
|
||||
(((T *)this)->*(r->_callback))();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1918,7 +1919,7 @@ void DreamGenContext::enterSymbol() {
|
||||
dumpPointer();
|
||||
dumpTextLine();
|
||||
dumpSymbol();
|
||||
RectWithCallback symbolList[] = {
|
||||
RectWithCallback<DreamGenContext> symbolList[] = {
|
||||
{ kSymbolx+40,kSymbolx+64,kSymboly+2,kSymboly+16,&DreamBase::quitSymbol },
|
||||
{ kSymbolx,kSymbolx+52,kSymboly+20,kSymboly+50,&DreamBase::setTopLeft },
|
||||
{ kSymbolx+52,kSymbolx+104,kSymboly+20,kSymboly+50,&DreamBase::setTopRight },
|
||||
@ -1998,7 +1999,7 @@ void DreamGenContext::showCity() {
|
||||
void DreamGenContext::mainScreen() {
|
||||
data.byte(kInmaparea) = 0;
|
||||
if (data.byte(kWatchon) == 1) {
|
||||
RectWithCallback mainList[] = {
|
||||
RectWithCallback<DreamGenContext> mainList[] = {
|
||||
{ 44,70,32,46,&DreamGenContext::look },
|
||||
{ 0,50,0,180,&DreamGenContext::inventory },
|
||||
{ 226,244,10,26,&DreamGenContext::zoomOnOff },
|
||||
@ -2009,7 +2010,7 @@ void DreamGenContext::mainScreen() {
|
||||
};
|
||||
checkCoords(mainList);
|
||||
} else {
|
||||
RectWithCallback mainList2[] = {
|
||||
RectWithCallback<DreamGenContext> mainList2[] = {
|
||||
{ 44,70,32,46,&DreamGenContext::look },
|
||||
{ 0,50,0,180,&DreamGenContext::inventory },
|
||||
{ 226+48,244+48,10,26,&DreamGenContext::zoomOnOff },
|
||||
@ -2476,7 +2477,7 @@ const uint8 *DreamBase::getTextInFile1(uint16 index) {
|
||||
}
|
||||
|
||||
void DreamGenContext::checkFolderCoords() {
|
||||
RectWithCallback folderList[] = {
|
||||
RectWithCallback<DreamGenContext> folderList[] = {
|
||||
{ 280,320,160,200, &DreamBase::quitKey },
|
||||
{ 143,300,6,194, &DreamGenContext::nextFolder },
|
||||
{ 0,143,6,194, &DreamGenContext::lastFolder },
|
||||
@ -2633,7 +2634,7 @@ void DreamGenContext::useMenu() {
|
||||
dumpPointer();
|
||||
dumpMenu();
|
||||
dumpTextLine();
|
||||
RectWithCallback menuList[] = {
|
||||
RectWithCallback<DreamGenContext> menuList[] = {
|
||||
{ kMenux+54,kMenux+68,kMenuy+72,kMenuy+88,&DreamBase::quitKey },
|
||||
{ 0,320,0,200,&DreamBase::blank },
|
||||
{ 0xFFFF,0,0,0,0 }
|
||||
@ -3559,7 +3560,7 @@ void DreamGenContext::selectLocation() {
|
||||
if (data.byte(kGetback) == 1)
|
||||
break;
|
||||
|
||||
RectWithCallback destList[] = {
|
||||
RectWithCallback<DreamGenContext> destList[] = {
|
||||
{ 238,258,4,44,&DreamGenContext::nextDest },
|
||||
{ 104,124,4,44,&DreamGenContext::lastDest },
|
||||
{ 280,308,4,44,&DreamGenContext::lookAtPlace },
|
||||
@ -3772,7 +3773,7 @@ void DreamGenContext::decide() {
|
||||
fadeScreenUp();
|
||||
data.byte(kGetback) = 0;
|
||||
|
||||
RectWithCallback decideList[] = {
|
||||
RectWithCallback<DreamGenContext> decideList[] = {
|
||||
{ kOpsx+69,kOpsx+124,kOpsy+30,kOpsy+76,&DreamGenContext::newGame },
|
||||
{ kOpsx+20,kOpsx+87,kOpsy+10,kOpsy+59,&DreamBase::DOSReturn },
|
||||
{ kOpsx+123,kOpsx+190,kOpsy+10,kOpsy+59,&DreamGenContext::loadOld },
|
||||
@ -3817,7 +3818,7 @@ void DreamGenContext::talk() {
|
||||
showPointer();
|
||||
workToScreenCPP();
|
||||
|
||||
RectWithCallback talkList[] = {
|
||||
RectWithCallback<DreamGenContext> talkList[] = {
|
||||
{ 273,320,157,198,&DreamBase::getBack1 },
|
||||
{ 240,290,2,44,&DreamGenContext::moreTalk },
|
||||
{ 0,320,0,200,&DreamBase::blank },
|
||||
@ -3853,7 +3854,7 @@ void DreamGenContext::talk() {
|
||||
void DreamGenContext::hangOnPQ() {
|
||||
data.byte(kGetback) = 0;
|
||||
|
||||
RectWithCallback quitList[] = {
|
||||
RectWithCallback<DreamGenContext> quitList[] = {
|
||||
{ 273,320,157,198,&DreamBase::getBack1 },
|
||||
{ 0,320,0,200,&DreamBase::blank },
|
||||
{ 0xFFFF,0,0,0,0 }
|
||||
|
@ -96,7 +96,7 @@
|
||||
}
|
||||
void walkAndExamine();
|
||||
void obName(uint8 command, uint8 commandType);
|
||||
void checkCoords(const RectWithCallback *rectWithCallbacks);
|
||||
|
||||
void getExPos();
|
||||
void compare();
|
||||
bool compare(uint8 index, uint8 flag, const char id[4]) {
|
||||
|
@ -1270,7 +1270,7 @@ void DreamGenContext::useDiary() {
|
||||
delPointer();
|
||||
data.byte(kGetback) = 0;
|
||||
|
||||
RectWithCallback diaryList[] = {
|
||||
RectWithCallback<DreamGenContext> diaryList[] = {
|
||||
{ kDiaryx+94,kDiaryx+110,kDiaryy+97,kDiaryy+113,&DreamBase::diaryKeyN },
|
||||
{ kDiaryx+151,kDiaryx+167,kDiaryy+71,kDiaryy+87,&DreamBase::diaryKeyP },
|
||||
{ kDiaryx+176,kDiaryx+192,kDiaryy+108,kDiaryy+124,&DreamBase::quitKey },
|
||||
|
Loading…
x
Reference in New Issue
Block a user