NEVERHOOD: Add Scene::setPalette for simpled palette creation and use it

This commit is contained in:
johndoe123 2011-09-19 14:46:53 +00:00 committed by Willem Jan Palenstijn
parent fa695229be
commit 2f670690bc
13 changed files with 69 additions and 117 deletions

View File

@ -353,8 +353,8 @@ DiskplayerScene::DiskplayerScene(NeverhoodEngine *vm, Module *parentModule, int
_surfaceFlag = true;
_background = addBackground(new DirtyBackground(_vm, 0x8A000044, 0, 0));
_palette = new Palette(_vm, kDiskplayerPaletteFileHashes[_which]);
setBackground(0x8A000044);
setPalette(kDiskplayerPaletteFileHashes[_which]);
_playButton = new DiskplayerPlayButton(_vm, this);
addSprite(_playButton);
_vm->_collisionMan->addSprite(_playButton);

View File

@ -103,16 +103,16 @@ public:
// NOTE: These were overloaded before for the various message parameter types
// it caused some problems so each type gets its own sendMessage variant now
uint32 sendMessage(Entity *receiver, int messageNum, const MessageParam &param) {
return receiver->receiveMessage(messageNum, param, this);
return receiver ? receiver->receiveMessage(messageNum, param, this) : 0;
}
uint32 sendMessage(Entity *receiver, int messageNum, uint32 param) {
return receiver->receiveMessage(messageNum, MessageParam(param), this);
return sendMessage(receiver, messageNum, MessageParam(param));
}
uint32 sendPointMessage(Entity *receiver, int messageNum, const NPoint &param) {
return receiver->receiveMessage(messageNum, MessageParam(param), this);
return sendMessage(receiver, messageNum, MessageParam(param));
}
uint32 sendEntityMessage(Entity *receiver, int messageNum, Entity *param) {
return receiver->receiveMessage(messageNum, MessageParam((Entity*)param), this);
return sendMessage(receiver, messageNum, MessageParam((Entity*)param));
}
int getPriority() const { return _priority; }
// Shortcuts for game variable access

View File

@ -82,30 +82,27 @@ void Module1000::updateScene() {
if (!updateChild()) {
switch (_vm->gameState().sceneNum) {
case 0:
if (_moduleResult == 2) {
if (_moduleResult == 2)
createScene(2, 0);
} else {
else
createScene(1, 0);
}
break;
case 1:
if (_moduleResult == 1) {
if (_moduleResult == 1)
sendMessage(_parentModule, 0x1009, 0);
} else if (_moduleResult == 2) {
else if (_moduleResult == 2)
createScene(3, 0);
} else {
else
createScene(0, 1);
}
break;
case 2:
createScene(0, 2);
break;
case 3:
if (_moduleResult == 1) {
if (_moduleResult == 1)
createScene(4, 0);
} else {
else
createScene(1, 2);
}
break;
case 4:
// TODO Music18hList_stop(_musicFileHash, 0, 1);
@ -213,9 +210,7 @@ uint32 AsScene1001Hammer::handleMessage(int messageNum, const MessageParam &para
switch (messageNum) {
case 0x100D:
if (param.asInteger() == 0x00352100) {
if (_asDoor) {
sendMessage(_asDoor, 0x2000, 0);
}
sendMessage(_asDoor, 0x2000, 0);
} else if (param.asInteger() == 0x0A1A0109) {
_soundResource.play(0x66410886);
}
@ -309,7 +304,7 @@ SsCommonButtonSprite::SsCommonButtonSprite(NeverhoodEngine *vm, Scene *parentSce
: StaticSprite(vm, fileHash, surfacePriority), _parentScene(parentScene), _soundResource(vm), _countdown(0) {
_priority = 1100;
_soundFileHash = soundFileHash != 0 ? soundFileHash : 0x44141000;
_soundFileHash = soundFileHash ? soundFileHash : 0x44141000;
setVisible(false);
SetUpdateHandler(&SsCommonButtonSprite::update);
SetMessageHandler(&SsCommonButtonSprite::handleMessage);
@ -346,8 +341,7 @@ Scene1001::Scene1001(NeverhoodEngine *vm, Module *parentModule, int which)
_vm->_collisionMan->setHitRects(0x004B4860);
_surfaceFlag = false;
setBackground(0x4086520E);
_palette = new Palette(_vm, 0x4086520E);
_palette->usePalette();
setPalette(0x4086520E);
insertMouse433(0x6520A400);
if (which < 0) {
@ -1349,8 +1343,7 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which)
_surfaceFlag = true;
setBackground(0x12C23307);
_palette = new Palette(_vm, 0x12C23307);
_palette->usePalette();
setPalette(0x12C23307);
_flag = false;
@ -1629,8 +1622,7 @@ Class152::Class152(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundF
SetMessageHandler(&Class152::handleMessage);
setBackground(backgroundFileHash);
_palette = new Palette(_vm, backgroundFileHash);
_palette->usePalette();
setPalette(backgroundFileHash);
insertMouse435(cursorFileHash, 20, 620);
}
@ -1692,13 +1684,12 @@ Scene1004::Scene1004(NeverhoodEngine *vm, Module *parentModule, int which)
setBackground(0x50C03005);
if (getGlobalVar(0x0D0A14D10)) {
_palette = new Palette(_vm, 0xA30BA329);
setPalette(0xA30BA329);
_palette->addBasePalette(0xA30BA329, 0, 256, 0);
} else {
_palette = new Palette(_vm, 0x50C03005);
setPalette(0x50C03005);
_palette->addBasePalette(0x50C03005, 0, 256, 0);
}
_palette->usePalette();
addEntity(_palette);
insertMouse433(0x03001504);
@ -1791,14 +1782,12 @@ Scene1005::Scene1005(NeverhoodEngine *vm, Module *parentModule, int which)
if (getGlobalVar(0xD0A14D10)) {
setBackground(0x2800E011);
_palette = new Palette(_vm, 0x2800E011);
_palette->usePalette();
setPalette(0x2800E011);
insertStaticSprite(0x492D5AD7, 100);
insertMouse435(0x0E015288, 20, 620);
} else {
setBackground(0x8870A546);
_palette = new Palette(_vm, 0x8870A546);
_palette->usePalette();
setPalette(0x8870A546);
insertStaticSprite(0x40D1E0A9, 100);
insertStaticSprite(0x149C00A6, 100);
insertMouse435(0x0A54288F, 20, 620);

View File

@ -838,13 +838,11 @@ Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which)
if (getGlobalVar(0x0A310817) && !getGlobalVar(0x0A18CA33)) {
setBackground(0x4019A2C4);
_palette = new Palette(_vm, 0x4019A2C4);
_palette->usePalette();
setPalette(0x4019A2C4);
_asRightDoor = NULL;
} else {
setBackground(0x40206EC5);
_palette = new Palette(_vm, 0x40206EC5);
_palette->usePalette();
setPalette(0x40206EC5);
_asRightDoor = addSprite(new AsScene1201RightDoor(_vm, _klayman, which == 2));
}
@ -1146,8 +1144,7 @@ Scene1202::Scene1202(NeverhoodEngine *vm, Module *parentModule, int which)
setBackground(0x60210ED5);
_palette = new Palette(_vm, 0x60210ED5);
_palette->usePalette();
setPalette(0x60210ED5);
addEntity(_palette);
_paletteResource.load(0x60250EB5);

View File

@ -421,8 +421,7 @@ Scene1302::Scene1302(NeverhoodEngine *vm, Module *parentModule, int which)
setRectList(0x004B0A38);
setBackground(0x420643C4);
_palette = new Palette(_vm, 0x420643C4);
_palette->usePalette();
setPalette(0x420643C4);
insertMouse433(0x643C0428);
_class595 = addSprite(new Class595(_vm, this));
@ -646,8 +645,7 @@ Scene1303::Scene1303(NeverhoodEngine *vm, Module *parentModule, int which)
setRectList(0x004AF9E8);
setBackground(0x01581A9C);
_palette = new Palette(_vm, 0x01581A9C);
_palette->usePalette();
setPalette(0x01581A9C);
insertMouse433(0x81A9801D);
if (!getGlobalVar(0xAC00C0D0)) {
@ -718,8 +716,7 @@ Scene1304::Scene1304(NeverhoodEngine *vm, Module *parentModule, int which)
setRectList(0x004B91A8);
setBackground(0x062C0214);
_palette = new Palette(_vm, 0x062C0214);
_palette->usePalette();
setPalette(0x062C0214);
insertMouse433(0xC021006A);
if (getGlobalVar(0xAC00C0D0)) {
@ -789,8 +786,7 @@ Scene1305::Scene1305(NeverhoodEngine *vm, Module *parentModule, int which)
setRectList(0x004B6E98);
setBackground(0x28801B64);
_palette = new Palette(_vm, 0x28801B64);
_palette->usePalette();
setPalette(0x28801B64);
insertMouse433(0x01B60280);
if (which < 0) {
@ -905,8 +901,7 @@ Scene1306::Scene1306(NeverhoodEngine *vm, Module *parentModule, int which)
SetMessageHandler(&Scene1306::handleMessage);
setBackground(0x05303114);
_palette = new Palette(_vm, 0x05303114);
_palette->usePalette();
setPalette(0x05303114);
insertMouse433(0x0311005B);
if (!getGlobalVar(0x13382860)) {
@ -1311,8 +1306,7 @@ Scene1307::Scene1307(NeverhoodEngine *vm, Module *parentModule, int which)
SetUpdateHandler(&Scene1307::update);
setBackground(0xA8006200);
_palette = new Palette(_vm, 0xA8006200);
_palette->usePalette();
setPalette(0xA8006200);
addEntity(_palette);
insertMouse435(0x06204A88, 20, 620);
@ -1630,8 +1624,7 @@ Scene1308::Scene1308(NeverhoodEngine *vm, Module *parentModule, int which)
SetMessageHandler(&Scene1308::handleMessage);
setBackground(0x41024202);
_palette = new Palette(_vm, 0x41024202);
_palette->usePalette();
setPalette(0x41024202);
insertMouse433(0x24206418);
_asTape = addSprite(new AsScene1201Tape(_vm, this, 17, 1100, 502, 445, 0x9148A011));

View File

@ -664,8 +664,7 @@ Scene1401::Scene1401(NeverhoodEngine *vm, Module *parentModule, int which)
_surfaceFlag = true;
setBackground(0x08221FA5);
_palette = new Palette(_vm, 0x08221FA5);
_palette->usePalette();
setPalette(0x08221FA5);
insertMouse433(0x21FA108A);
// TODO _class427 = addSprite(new Class427(_vm, this, 0x980F3124, 0x12192892, 100, 0));
@ -885,9 +884,8 @@ Scene1402::Scene1402(NeverhoodEngine *vm, Module *parentModule, int which)
_background = addBackground(new Background(_vm, 0x231482F0, 0, 0));
_background->getSurface()->getDrawRect().y = -10;
// TODO g_screen->field_26 = 0;
_palette = new Palette(_vm, 0x231482F0);
setPalette(0x231482F0);
_palette->addPalette(0x91D3A391, 0, 64, 0);
_palette->usePalette();
insertMouse433(0x482F4239);
_class454_1 = addSprite(new Class454(_vm, 0x15402D64, 1100));
@ -1288,8 +1286,7 @@ Scene1407::Scene1407(NeverhoodEngine *vm, Module *parentModule, int which)
SetUpdateHandler(&Scene1407::update);
setBackground(0x00442225);
_palette = new Palette(_vm, 0x00442225);
_palette->usePalette();
setPalette(0x00442225);
insertMouse435(0x4222100C, 20, 620);
_asMouse = addSprite(new AsScene1407Mouse(_vm, this));
@ -1354,8 +1351,7 @@ Scene1403::Scene1403(NeverhoodEngine *vm, Module *parentModule, int which)
_surfaceFlag = true;
setBackground(0x2110A234);
_palette = new Palette(_vm, 0x2110A234);
_palette->usePalette();
setPalette(0x2110A234);
insertMouse433(0x0A230219);
_class401_1 = insertStaticSprite(0x01102A33, 100);
@ -1477,9 +1473,8 @@ Scene1404::Scene1404(NeverhoodEngine *vm, Module *parentModule, int which)
setRectList(0x004B8D80);
setBackground(0xAC0B006F);
_palette = new Palette(_vm, 0xAC0B006F);
setPalette(0xAC0B006F);
_palette->addPalette(0x00801510, 0, 65, 0);
_palette->usePalette();
insertMouse433(0xB006BAC8);
if (getGlobalVar(0x13382860) == 5) {
@ -1692,8 +1687,7 @@ Scene1405::Scene1405(NeverhoodEngine *vm, Module *parentModule, int which)
_surfaceFlag = true;
setBackground(0x0C0C007D);
_palette = new Palette(_vm, 0x0C0C007D);
_palette->usePalette();
setPalette(0x0C0C007D);
insertMouse435(0xC00790C8, 20, 620);
// TODO: Some debug code: Leave two matching tiles open

View File

@ -93,8 +93,7 @@ Scene1501::Scene1501(NeverhoodEngine *vm, Module *parentModule, uint32 backgroun
setBackground(backgroundFileHash);
_palette = new Palette(_vm);
_palette->usePalette();
setPalette();
addEntity(_palette);
_palette->addBasePalette(backgroundFileHash, 0, 256, 0);
_palette->startFadeToPalette(12);

View File

@ -188,10 +188,9 @@ Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which)
setBackground(0x03118226);
_palette = new Palette(_vm, 0x03118226);
setPalette(0x03118226);
_palette->addBasePalette(0x91D3A391, 0, 64, 0);
_palette->copyBasePalette(0, 256, 0);
_palette->usePalette();
addEntity(_palette);
insertMouse433(0x18222039);

View File

@ -102,8 +102,7 @@ Scene2001::Scene2001(NeverhoodEngine *vm, Module *parentModule, int which)
SetMessageHandler(&Scene2001::handleMessage);
setBackground(0xA6417244);
_palette = new Palette(_vm, 0xA6417244);
_palette->usePalette();
setPalette(0xA6417244);
insertMouse433(0x17240A6C);
_class401 = insertStaticSprite(0x0D641724, 1100);

View File

@ -736,8 +736,7 @@ Scene2201::Scene2201(NeverhoodEngine *vm, Module *parentModule, int which)
loadHitRectList();
setBackground(0x40008208);
_palette = new Palette(_vm, 0x40008208);
_palette->usePalette();
setPalette(0x40008208);
insertMouse433(0x0820C408);
_asTape = addSprite(new AsScene1201Tape(_vm, this, 7, 1100, 459, 432, 0x9148A011));
@ -1119,8 +1118,7 @@ Scene2202::Scene2202(NeverhoodEngine *vm, Module *parentModule, int which)
_surfaceFlag = true;
setBackground(0x08100A0C);
_palette = new Palette(_vm, 0x08100A0C);
_palette->usePalette();
setPalette(0x08100A0C);
addEntity(_palette);
insertMouse435(0x00A08089, 20, 620);
@ -1349,8 +1347,7 @@ Scene2203::Scene2203(NeverhoodEngine *vm, Module *parentModule, int which)
_surfaceFlag = true;
setBackground(0x82C80334);
_palette = new Palette(_vm, 0x82C80334);
_palette->usePalette();
setPalette(0x82C80334);
insertMouse433(0x80330824);
_vm->_collisionMan->setHitRects(0x004B8320);
@ -1512,8 +1509,7 @@ Scene2205::Scene2205(NeverhoodEngine *vm, Module *parentModule, int which)
if (getGlobalVar(0x4D080E54)) {
_isLightOn = true;
setBackground(0x0008028D);
_palette = new Palette(_vm, 0x0008028D);
_palette->usePalette();
setPalette(0x0008028D);
addEntity(_palette);
insertMouse433(0x80289008);
_ssLightSwitch = new Class426(_vm, this, 0x2D339030, 0x2D309030, 100, 0);
@ -1521,8 +1517,7 @@ Scene2205::Scene2205(NeverhoodEngine *vm, Module *parentModule, int which)
} else {
_isLightOn = false;
setBackground(0xD00A028D);
_palette = new Palette(_vm, 0xD00A028D);
_palette->usePalette();
setPalette(0xD00A028D);
addEntity(_palette);
insertMouse433(0xA0289D08);
_ssLightSwitch = new Class426(_vm, this, 0x2D339030, 0xDAC86E84, 100, 0);
@ -1807,8 +1802,7 @@ Scene2206::Scene2206(NeverhoodEngine *vm, Module *parentModule, int which)
setBackground(fileHash);
_palette = new Palette(_vm, fileHash);
_palette->usePalette();
setPalette(fileHash);
addEntity(_palette);
_palette->addBasePalette(fileHash, 0, 256, 0);
@ -2292,8 +2286,7 @@ Scene2207::Scene2207(NeverhoodEngine *vm, Module *parentModule, int which)
if (getGlobalVar(0x4D080E54)) {
setBackground(0x88C00241);
_palette = new Palette(_vm, 0x88C00241);
_palette->usePalette();
setPalette(0x88C00241);
insertMouse433(0x00245884);
_ssMaskPart1 = insertStaticSprite(0xE20A28A0, 1200);
@ -2334,8 +2327,7 @@ Scene2207::Scene2207(NeverhoodEngine *vm, Module *parentModule, int which)
setGlobalVar(0x81890D14, 1);
setBackground(0x05C02A55);
_palette = new Palette(_vm, 0x05C02A55);
_palette->usePalette();
setPalette(0x05C02A55);
insertMouse433(0x02A51054);
_ssMaskPart1 = insertStaticSprite(0x980E46A4, 1200);
@ -2531,8 +2523,7 @@ Scene2208::Scene2208(NeverhoodEngine *vm, Module *parentModule, int which)
_background->getSpriteResource().getPosition().y = 480;
addBackground(_background);
_palette = new Palette(_vm, 0x08100289);
_palette->usePalette();
setPalette(0x08100289);
addEntity(_palette); // Why?
insertMouse435(0x0028D089, 40, 600);
@ -2708,14 +2699,12 @@ Scene2242::Scene2242(NeverhoodEngine *vm, Module *parentModule, int which)
if (getGlobalVar(0x4D080E54)) {
setBackground(0x11840E24);
_palette = new Palette(_vm, 0x11840E24);
_palette->usePalette();
setPalette(0x11840E24);
insertMouse433(0x40E20110);
setRectList(0x004B3DC8);
} else {
setBackground(0x25848E24);
_palette = new Palette(_vm, 0x25848E24);
_palette->usePalette();
setPalette(0x25848E24);
addEntity(_palette);
_palette->copyBasePalette(0, 256, 0);
_palette->addPalette(0x68033B1C, 0, 65, 0);
@ -2846,14 +2835,12 @@ HallOfRecordsScene::HallOfRecordsScene(NeverhoodEngine *vm, Module *parentModule
if (!getGlobalVar(0x4D080E54) && _sceneInfo140->bgFilename2) {
setRectList(0x004B2BF8);
setBackground(_sceneInfo140->bgFilename2);
_palette = new Palette(_vm, _sceneInfo140->bgFilename2);
_palette->usePalette();
setPalette(_sceneInfo140->bgFilename2);
insertMouse433(0x14320138);
} else {
setRectList(0x004B2BB8);
setBackground(_sceneInfo140->bgFilename1);
_palette = new Palette(_vm, _sceneInfo140->bgFilename1);
_palette->usePalette();
setPalette(_sceneInfo140->bgFilename1);
insertMouse433(0x63A40028);
}
@ -2943,14 +2930,12 @@ Scene2247::Scene2247(NeverhoodEngine *vm, Module *parentModule, int which)
if (getGlobalVar(0x4D080E54)) {
setRectList(0x004B5588);
setBackground(0x40339414);
_palette = new Palette(_vm, 0x40339414);
_palette->usePalette();
setPalette(0x40339414);
insertMouse433(0x3941040B);
} else {
setRectList(0x004B55C8);
setBackground(0x071963E5);
_palette = new Palette(_vm, 0x071963E5);
_palette->usePalette();
setPalette(0x071963E5);
insertMouse433(0x14320138);
}

View File

@ -795,7 +795,7 @@ Scene3009::Scene3009(NeverhoodEngine *vm, Module *parentModule, int which)
_vm->_screen->clear();
setBackground(0xD000420C);
_palette = new Palette(_vm, 0xD000420C);
setPalette(0xD000420C);
insertMouse435(0x04208D08, 20, 620);
_ssFireCannonButton = addSprite(new SsScene3009FireCannonButton(_vm, this));
@ -821,7 +821,7 @@ Scene3009::Scene3009(NeverhoodEngine *vm, Module *parentModule, int which)
_smackerPlayer = addSmackerPlayer(new SmackerPlayer(_vm, this, kScene3009SmackerFileHashes[_cannonLocation], false, _keepVideo));
_smackerPlayer->setDrawPos(89, 37);
_palette->usePalette();
_palette->usePalette(); // Use it again since the SmackerPlayer overrides the usage
insertStaticSprite(0x8540252C, 400);
@ -1032,7 +1032,7 @@ bool Scene3009::isSymbolsPart2Solved() {
}
bool Scene3009::sub462E90() {
return /*_flag3 || */_flag4;
return _flag4;
}
// Scene3010
@ -1153,10 +1153,7 @@ void SsScene3010DeadBoltButton::setSprite(uint32 fileHash) {
_drawRect.y = 0;
_drawRect.width = _spriteResource.getDimensions().width;
_drawRect.height = _spriteResource.getDimensions().height;
_deltaRect.x = 0;
_deltaRect.y = 0;
_deltaRect.width = _spriteResource.getDimensions().width;
_deltaRect.height = _spriteResource.getDimensions().height;
_deltaRect = _drawRect;
processDelta();
_needRefresh = true;
StaticSprite::update();
@ -1294,8 +1291,7 @@ Scene3010::Scene3010(NeverhoodEngine *vm, Module *parentModule, int which)
_surfaceFlag = true;
setBackground(0x80802626);
_palette = new Palette(_vm, 0x80802626);
_palette->usePalette();
setPalette(0x80802626);
for (int i = 0; i < 3; i++) {
_asDeadBolts[i] = new AsScene3010DeadBolt(_vm, this, i, which == 1);//CHECKME
@ -1443,10 +1439,7 @@ SsScene3011Button::SsScene3011Button(NeverhoodEngine *vm, Scene *parentScene, bo
_drawRect.y = 0;
_drawRect.width = _spriteResource.getDimensions().width;
_drawRect.height = _spriteResource.getDimensions().height;
_deltaRect.x = 0;
_deltaRect.y = 0;
_deltaRect.width = _spriteResource.getDimensions().width;
_deltaRect.height = _spriteResource.getDimensions().height;
_deltaRect = _drawRect;
setVisible(false);
processDelta();
_needRefresh = true;
@ -1546,9 +1539,7 @@ Scene3011::Scene3011(NeverhoodEngine *vm, Module *parentModule, int which)
_index1 = getGlobalVar(0x2414C2F2);
setBackground(0x92124A04);
_palette = new Palette(_vm, 0xA4070114);
_palette->usePalette();
setPalette(0xA4070114);
addEntity(_palette);
insertMouse435(0x24A00929, 20, 620);

View File

@ -186,6 +186,11 @@ void Scene::changeBackground(uint32 fileHash) {
_background->load(fileHash);
}
void Scene::setPalette(uint32 fileHash) {
_palette = fileHash ? new Palette(_vm, fileHash) : new Palette(_vm);
_palette->usePalette();
}
Sprite *Scene::insertStaticSprite(uint32 fileHash, int surfacePriority) {
return addSprite(new StaticSprite(_vm, fileHash, surfacePriority));
}

View File

@ -55,6 +55,7 @@ public:
Background *addBackground(Background *background);
void setBackground(uint32 fileHash, bool dirtyBackground = true);
void changeBackground(uint32 fileHash);
void setPalette(uint32 fileHash = 0);
Sprite *insertStaticSprite(uint32 fileHash, int surfacePriority);
void insertMouse433(uint32 fileHash, NRect *mouseRect = NULL);
void insertMouse435(uint32 fileHash, int16 x1, int16 x2);