aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood
diff options
context:
space:
mode:
authorjohndoe1232013-01-25 13:47:06 +0000
committerWillem Jan Palenstijn2013-05-08 20:47:42 +0200
commit65c6984635849f451d2137a37407813a3ada105e (patch)
tree4d5164291a5344590d872c9e02dbf5fe235560c7 /engines/neverhood
parent9ae1888593ae25680a53819a038e9123db30b038 (diff)
downloadscummvm-rg350-65c6984635849f451d2137a37407813a3ada105e.tar.gz
scummvm-rg350-65c6984635849f451d2137a37407813a3ada105e.tar.bz2
scummvm-rg350-65c6984635849f451d2137a37407813a3ada105e.zip
NEVERHOOD: Implement game-internal savegame overwrite query screen
- Rename and reorder fields in the Klaymen class
Diffstat (limited to 'engines/neverhood')
-rw-r--r--engines/neverhood/klaymen.cpp8
-rw-r--r--engines/neverhood/klaymen.h8
-rw-r--r--engines/neverhood/menumodule.cpp84
-rw-r--r--engines/neverhood/menumodule.h9
4 files changed, 85 insertions, 24 deletions
diff --git a/engines/neverhood/klaymen.cpp b/engines/neverhood/klaymen.cpp
index 2563ce000c..06d606e18d 100644
--- a/engines/neverhood/klaymen.cpp
+++ b/engines/neverhood/klaymen.cpp
@@ -62,7 +62,7 @@ static const KlaymenIdleTableItem klaymenIdleTable1002[] = {
Klaymen::Klaymen(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 y, NRectArray *clipRects)
: AnimatedSprite(vm, 1000), _idleCounterMax(0), _idleCounter(0), _isMoveObjectRequested(false), _blinkCounterMax(0),
- _isWalkingOpenDoorNotified(false), _countdown1(0), _tapesToInsert(0), _keysToInsert(0), _busyStatus(0), _acceptInput(true),
+ _isWalkingOpenDoorNotified(false), _spitOutCountdown(0), _tapesToInsert(0), _keysToInsert(0), _busyStatus(0), _acceptInput(true),
_attachedSprite(NULL), _isWalking(false), _actionStatus(1), _parentScene(parentScene), _isSneaking(false), _isLargeStep(false),
_doYHitIncr(false), _isLeverDown(false), _isSittingInTeleporter(false), _actionStatusChanged(false), _ladderStatus(0), _pathPoints(NULL), _soundFlag(false),
_idleTableNum(0), _otherSprite(NULL), _moveObjectCountdown(0), _readyToSpit(false), _walkResumeFrameIncr(0) {
@@ -2718,7 +2718,7 @@ void Klaymen::stCrashDownFinished() {
void Klaymen::upSpitOutFall() {
Klaymen::update();
- if (_countdown1 != 0 && (--_countdown1 == 0)) {
+ if (_spitOutCountdown != 0 && (--_spitOutCountdown == 0)) {
_surface->setVisible(true);
SetUpdateHandler(&Klaymen::update);
}
@@ -2902,7 +2902,7 @@ void Klaymen::stStandIdleSpecial() {
}
void Klaymen::stSpitOutFall0() {
- _countdown1 = 1;
+ _spitOutCountdown = 1;
_busyStatus = 0;
_acceptInput = false;
startAnimation(0x000BAB02, 0, -1);
@@ -2914,7 +2914,7 @@ void Klaymen::stSpitOutFall0() {
}
void Klaymen::stSpitOutFall2() {
- _countdown1 = 1;
+ _spitOutCountdown = 1;
_busyStatus = 0;
_acceptInput = false;
startAnimation(0x9308C132, 0, -1);
diff --git a/engines/neverhood/klaymen.h b/engines/neverhood/klaymen.h
index d1b0b5974b..25443b5a35 100644
--- a/engines/neverhood/klaymen.h
+++ b/engines/neverhood/klaymen.h
@@ -401,7 +401,6 @@ protected:
int16 _destX, _destY;
int16 _idleCounter, _idleCounterMax;
int16 _blinkCounter, _blinkCounterMax;
- int16 _countdown1;
int16 _tapesToInsert, _keysToInsert;
bool _doYHitIncr;
bool _isLeverDown;
@@ -409,12 +408,17 @@ protected:
int _busyStatus;
bool _actionStatusChanged;
int _actionStatus;
+
const KlaymenIdleTableItem *_idleTable;
uint _idleTableCount;
int _idleTableTotalWeight;
+ int _idleTableNum;
+
NPointArray *_pathPoints;
bool _soundFlag;
+ int16 _spitOutCountdown;
+
bool _isSittingInTeleporter;
bool _potionFlag1;
@@ -423,7 +427,6 @@ protected:
int16 _platformDeltaY;
Sprite *_otherSprite;
- int _idleTableNum;
int16 _walkResumeFrameIncr;
@@ -437,7 +440,6 @@ protected:
uint32 _spitContDestPipeIndex;
virtual void xUpdate();
- // TODO Check if this can be turned into a void result
virtual uint32 xHandleMessage(int messageNum, const MessageParam &param);
void startWalkToX(int16 x, bool walkExt);
diff --git a/engines/neverhood/menumodule.cpp b/engines/neverhood/menumodule.cpp
index 396d8cfb30..f1669a6213 100644
--- a/engines/neverhood/menumodule.cpp
+++ b/engines/neverhood/menumodule.cpp
@@ -32,7 +32,8 @@ enum {
CREDITS_SCENE = 1,
MAKING_OF = 2,
LOAD_GAME_MENU = 3,
- SAVE_GAME_MENU = 4
+ SAVE_GAME_MENU = 4,
+ QUERY_OVR_MENU = 5
};
enum {
@@ -109,6 +110,9 @@ void MenuModule::createScene(int sceneNum, int which) {
case SAVE_GAME_MENU:
createSaveGameMenu();
break;
+ case QUERY_OVR_MENU:
+ _childObject = new QueryOverwriteMenu(_vm, this, _savegameDescription);
+ break;
}
SetUpdateHandler(&MenuModule::updateScene);
_childObject->handleUpdate();
@@ -162,7 +166,10 @@ void MenuModule::updateScene() {
handleLoadGameMenuAction(_moduleResult != 1);
break;
case SAVE_GAME_MENU:
- handleSaveGameMenuAction(_moduleResult != 1);
+ handleSaveGameMenuAction(_moduleResult != 1, true);
+ break;
+ case QUERY_OVR_MENU:
+ handleSaveGameMenuAction(_moduleResult != 1, false);
break;
default:
break;
@@ -199,16 +206,19 @@ void MenuModule::handleLoadGameMenuAction(bool doLoad) {
_savegameList = NULL;
}
-void MenuModule::handleSaveGameMenuAction(bool doSave) {
- createScene(MAIN_MENU, -1);
- if (doSave && _savegameSlot >= 0) {
+void MenuModule::handleSaveGameMenuAction(bool doSave, bool doQuery) {
+ if (doSave && doQuery && _savegameSlot >= 0 && _savegameSlot < (int)_savegameList->size()) {
+ createScene(QUERY_OVR_MENU, -1);
+ } else if (doSave && _savegameSlot >= 0) {
// Restore the scene palette and background so that the correct thumbnail is saved
byte *menuPaletteData = _vm->_screen->getPaletteData();
_vm->_screen->setPaletteData(_savedPaletteData);
_vm->_gameModule->redrawPrevChildObject();
_vm->saveGameState(_savegameSlot, _savegameDescription);
_vm->_screen->setPaletteData(menuPaletteData);
- leaveModule(0);
+ createScene(MAIN_MENU, -1);
+ } else {
+ createScene(MAIN_MENU, -1);
}
delete _savegameList;
_savegameList = NULL;
@@ -1010,22 +1020,13 @@ void LoadGameMenu::handleEvent(int16 itemID, int eventType) {
uint32 LoadGameMenu::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
Scene::handleMessage(messageNum, param, sender);
switch (messageNum) {
-#if 0
- case 0x000A:
- sendMessage(_textEditWidget, 0x000A, param.asInteger());
- setCurrWidget(_textEditWidget);
- break;
-#endif
case 0x000B:
if (param.asInteger() == Common::KEYCODE_RETURN) {
((MenuModule*)_parentModule)->setLoadgameInfo(_listBox->getCurrIndex());
leaveScene(0);
} else if (param.asInteger() == Common::KEYCODE_ESCAPE) {
leaveScene(1);
- }/* else {
- sendMessage(_textEditWidget, 0x000B, param.asInteger());
- setCurrWidget(_textEditWidget);
- }*/
+ }
break;
case 0x2000:
// Handle menu button click
@@ -1056,4 +1057,55 @@ uint32 LoadGameMenu::handleMessage(int messageNum, const MessageParam &param, En
return 0;
}
+QueryOverwriteMenu::QueryOverwriteMenu(NeverhoodEngine *vm, Module *parentModule, const Common::String &description)
+ : Scene(vm, parentModule) {
+
+ static const uint32 kQueryOverwriteMenuButtonFileHashes[] = {
+ 0x90312400,
+ 0x94C22A22
+ };
+
+ static const NRect kQueryOverwriteMenuCollisionBounds[] = {
+ NRect(145, 334, 260, 385),
+ NRect(365, 340, 477, 388)
+ };
+
+ setBackground(0x043692C4);
+ setPalette(0x043692C4);
+ insertScreenMouse(0x692C004B);
+ insertStaticSprite(0x08C0AC24, 200);
+
+ for (uint buttonIndex = 0; buttonIndex < 2; ++buttonIndex) {
+ Sprite *menuButton = insertSprite<MenuButton>(this, buttonIndex,
+ kQueryOverwriteMenuButtonFileHashes[buttonIndex], kQueryOverwriteMenuCollisionBounds[buttonIndex]);
+ addCollisionSprite(menuButton);
+ }
+
+ // Draw the query text to the background, each text line is centered
+ // NOTE The original had this in its own class
+ FontSurface *fontSurface = new FontSurface(_vm, calcHash("bgQueryTinyAlphabet"), 32, 7, 32, 11, 17);
+ Common::StringArray textLines;
+ textLines.push_back(description);
+ textLines.push_back("Game exists.");
+ textLines.push_back("Overwrite it?");
+ for (uint i = 0; i < textLines.size(); ++i)
+ fontSurface->drawString(_background->getSurface(), 106 + (423 - textLines[i].size() * 11) / 2,
+ 127 + 31 + i * 17, (const byte*)textLines[i].c_str());
+ delete fontSurface;
+
+ SetUpdateHandler(&Scene::update);
+ SetMessageHandler(&QueryOverwriteMenu::handleMessage);
+}
+
+uint32 QueryOverwriteMenu::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ Scene::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x2000:
+ // Handle menu button click
+ leaveScene(param.asInteger());
+ break;
+ }
+ return 0;
+}
+
} // End of namespace Neverhood
diff --git a/engines/neverhood/menumodule.h b/engines/neverhood/menumodule.h
index 083679571b..de25b69ac1 100644
--- a/engines/neverhood/menumodule.h
+++ b/engines/neverhood/menumodule.h
@@ -49,7 +49,7 @@ protected:
void createLoadGameMenu();
void createSaveGameMenu();
void handleLoadGameMenuAction(bool doLoad);
- void handleSaveGameMenuAction(bool doSave);
+ void handleSaveGameMenuAction(bool doSave, bool doQuery);
void loadSavegameList();
};
@@ -235,6 +235,13 @@ protected:
SavegameListBox *_listBox;
TextEditWidget *_textEditWidget;
Common::String _savegameDescription;
+ uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+};
+
+class QueryOverwriteMenu : public Scene {
+public:
+ QueryOverwriteMenu(NeverhoodEngine *vm, Module *parentModule, const Common::String &description);
+protected:
void update();
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
};