Skeleton code added for restart/restore screen
svn-id: r28548
This commit is contained in:
parent
48499f3a52
commit
81fa23f091
3 changed files with 77 additions and 30 deletions
|
@ -24,12 +24,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lure/game.h"
|
#include "lure/game.h"
|
||||||
#include "lure/strings.h"
|
|
||||||
#include "lure/room.h"
|
|
||||||
#include "lure/scripts.h"
|
|
||||||
#include "lure/res_struct.h"
|
|
||||||
#include "lure/animseq.h"
|
#include "lure/animseq.h"
|
||||||
#include "lure/fights.h"
|
#include "lure/fights.h"
|
||||||
|
#include "lure/res_struct.h"
|
||||||
|
#include "lure/room.h"
|
||||||
|
#include "lure/scripts.h"
|
||||||
|
#include "lure/sound.h"
|
||||||
|
#include "lure/strings.h"
|
||||||
|
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ Game::Game() {
|
||||||
int_game = this;
|
int_game = this;
|
||||||
_debugger = new Debugger();
|
_debugger = new Debugger();
|
||||||
_slowSpeedFlag = true;
|
_slowSpeedFlag = true;
|
||||||
|
_preloadFlag = true;
|
||||||
_soundFlag = true;
|
_soundFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +54,7 @@ Game::~Game() {
|
||||||
delete _debugger;
|
delete _debugger;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::tick(bool fastSpeed) {
|
void Game::tick() {
|
||||||
// Call the tick method for each hotspot - this is somewaht complicated
|
// Call the tick method for each hotspot - this is somewaht complicated
|
||||||
// by the fact that a tick proc can unload both itself and/or others,
|
// by the fact that a tick proc can unload both itself and/or others,
|
||||||
// so we first get a list of the Ids, and call the tick proc for each
|
// so we first get a list of the Ids, and call the tick proc for each
|
||||||
|
@ -66,7 +68,7 @@ void Game::tick(bool fastSpeed) {
|
||||||
for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) {
|
for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) {
|
||||||
Hotspot *hotspot = *i;
|
Hotspot *hotspot = *i;
|
||||||
|
|
||||||
if (!fastSpeed || ((hotspot->layer() != 0xff) &&
|
if (!_preloadFlag || ((hotspot->layer() != 0xff) &&
|
||||||
(hotspot->hotspotId() < FIRST_NONCHARACTER_ID)))
|
(hotspot->hotspotId() < FIRST_NONCHARACTER_ID)))
|
||||||
// Add hotspot to list to execute
|
// Add hotspot to list to execute
|
||||||
idList[idSize++] = hotspot->hotspotId();
|
idList[idSize++] = hotspot->hotspotId();
|
||||||
|
@ -85,6 +87,21 @@ void Game::tick(bool fastSpeed) {
|
||||||
delete[] idList;
|
delete[] idList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::tickCheck() {
|
||||||
|
Resources &res = Resources::getReference();
|
||||||
|
Room &room = Room::getReference();
|
||||||
|
bool remoteFlag = res.fieldList().getField(OLD_ROOM_NUMBER) != 0;
|
||||||
|
|
||||||
|
_state |= GS_TICK;
|
||||||
|
if ((room.roomNumber() == ROOMNUM_VILLAGE_SHOP) && !remoteFlag && ((_state & GS_TICK) != 0)) {
|
||||||
|
// In the village shop,
|
||||||
|
bool tockFlag = (_state & GS_TOCK) != 0;
|
||||||
|
Sound.addSound(tockFlag ? 16 : 50);
|
||||||
|
|
||||||
|
_state = _state ^ (GS_TICK | GS_TOCK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Game::nextFrame() {
|
void Game::nextFrame() {
|
||||||
Resources &res = Resources::getReference();
|
Resources &res = Resources::getReference();
|
||||||
Room &room = Room::getReference();
|
Room &room = Room::getReference();
|
||||||
|
@ -110,13 +127,14 @@ void Game::execute() {
|
||||||
ValueTableData &fields = res.fieldList();
|
ValueTableData &fields = res.fieldList();
|
||||||
|
|
||||||
uint32 timerVal = system.getMillis();
|
uint32 timerVal = system.getMillis();
|
||||||
|
uint32 timerVal2 = system.getMillis();
|
||||||
|
|
||||||
screen.empty();
|
screen.empty();
|
||||||
//_screen.resetPalette();
|
//_screen.resetPalette();
|
||||||
screen.setPaletteEmpty();
|
screen.setPaletteEmpty();
|
||||||
|
|
||||||
|
while (!events.quitFlag) {
|
||||||
setState(0);
|
setState(0);
|
||||||
|
|
||||||
Script::execute(STARTUP_SCRIPT);
|
Script::execute(STARTUP_SCRIPT);
|
||||||
|
|
||||||
int bootParam = ConfMan.getInt("boot_param");
|
int bootParam = ConfMan.getInt("boot_param");
|
||||||
|
@ -128,13 +146,22 @@ void Game::execute() {
|
||||||
room.update();
|
room.update();
|
||||||
mouse.setCursorNum(CURSOR_ARROW);
|
mouse.setCursorNum(CURSOR_ARROW);
|
||||||
mouse.cursorOn();
|
mouse.cursorOn();
|
||||||
|
if (bootParam == 1) _state = GS_RESTORE_RESTART; //******DEBUG******
|
||||||
|
|
||||||
while (!events.quitFlag) {
|
// Main game loop
|
||||||
while (!events.quitFlag && (_state == 0)) {
|
while (!events.quitFlag && ((_state & GS_RESTART) == 0)) {
|
||||||
// If time for next frame, allow everything to update
|
// If time for next frame, allow everything to update
|
||||||
if (system.getMillis() > timerVal + GAME_FRAME_DELAY) {
|
if (system.getMillis() > timerVal + GAME_FRAME_DELAY) {
|
||||||
timerVal = system.getMillis();
|
timerVal = system.getMillis();
|
||||||
nextFrame();
|
nextFrame();
|
||||||
|
|
||||||
|
Sound.musicInterface_ContinuePlaying();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also check if time to do another village shop tick check
|
||||||
|
if (system.getMillis() > timerVal2 + GAME_TICK_DELAY) {
|
||||||
|
timerVal2 = system.getMillis();
|
||||||
|
tickCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
res.delayList().tick();
|
res.delayList().tick();
|
||||||
|
@ -232,24 +259,35 @@ void Game::execute() {
|
||||||
_debugger->onFrame();
|
_debugger->onFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
room.leaveRoom();
|
||||||
|
screen.paletteFadeOut();
|
||||||
|
|
||||||
// If Skorl catches player, show the catching animation
|
// If Skorl catches player, show the catching animation
|
||||||
if ((_state & GS_CAUGHT) != 0) {
|
if ((_state & GS_CAUGHT) != 0) {
|
||||||
Palette palette(SKORL_CATCH_PALETTE_ID);
|
Palette palette(SKORL_CATCH_PALETTE_ID);
|
||||||
AnimationSequence *anim = new AnimationSequence(screen, system,
|
AnimationSequence *anim = new AnimationSequence(screen, system,
|
||||||
SKORL_CATCH_ANIM_ID, palette, false);
|
SKORL_CATCH_ANIM_ID, palette, false);
|
||||||
mouse.cursorOff();
|
mouse.cursorOff();
|
||||||
|
Sound.addSound(0x33);
|
||||||
anim->show();
|
anim->show();
|
||||||
mouse.cursorOn();
|
mouse.cursorOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the Restart/Restore dialog is needed, show it
|
// If the Restart/Restore dialog is needed, show it
|
||||||
if ((_state & GS_RESTORE_RESTART) != 0) {
|
if ((_state & GS_RESTORE) != 0) {
|
||||||
// TODO: Restore/Restart dialog - for now, simply flag for exit
|
// Show the Restore/Restart dialog
|
||||||
|
bool restartFlag = RestartRestoreDialog::show();
|
||||||
|
|
||||||
|
setState(0);
|
||||||
|
|
||||||
|
if (restartFlag) {
|
||||||
|
res.reloadData();
|
||||||
|
Script::execute(STARTUP_SCRIPT);
|
||||||
|
}
|
||||||
|
} else if ((_state & GS_RESTART) == 0)
|
||||||
|
// Exiting game
|
||||||
events.quitFlag = true;
|
events.quitFlag = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
room.leaveRoom();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::handleMenuResponse(uint8 selection) {
|
void Game::handleMenuResponse(uint8 selection) {
|
||||||
|
@ -296,6 +334,8 @@ void Game::playerChangeRoom() {
|
||||||
|
|
||||||
delayList.clear();
|
delayList.clear();
|
||||||
|
|
||||||
|
Sound.removeSounds();
|
||||||
|
|
||||||
RoomData *roomData = res.getRoom(roomNum);
|
RoomData *roomData = res.getRoom(roomNum);
|
||||||
assert(roomData);
|
assert(roomData);
|
||||||
roomData->flags |= HOTSPOTFLAG_FOUND;
|
roomData->flags |= HOTSPOTFLAG_FOUND;
|
||||||
|
@ -361,7 +401,7 @@ void Game::displayChuteAnimation()
|
||||||
delete anim;
|
delete anim;
|
||||||
|
|
||||||
mouse.cursorOn();
|
mouse.cursorOn();
|
||||||
fields.setField(82, 1);
|
fields.setField(AREA_FLAG, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::displayBarrelAnimation()
|
void Game::displayBarrelAnimation()
|
||||||
|
|
|
@ -39,7 +39,9 @@
|
||||||
|
|
||||||
namespace Lure {
|
namespace Lure {
|
||||||
|
|
||||||
enum GameState {GS_RESTORE_RESTART = 1, GS_CAUGHT = 2, GS_EXIT = 3};
|
enum GameState {GS_ERROR = 1, GS_TICK = 2, GS_TOCK = 4, GS_PROT = 8, GS_RESTART = 0x10,
|
||||||
|
GS_CAUGHT = 0x20, GS_RESTORE = 0x40, GS_FLOPPY = 0x80,
|
||||||
|
GS_RESTORE_RESTART = 0x50};
|
||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
private:
|
private:
|
||||||
|
@ -48,6 +50,7 @@ private:
|
||||||
uint8 _state;
|
uint8 _state;
|
||||||
uint16 _tellCommands[MAX_TELL_COMMANDS * 3 + 1];
|
uint16 _tellCommands[MAX_TELL_COMMANDS * 3 + 1];
|
||||||
int _numTellCommands;
|
int _numTellCommands;
|
||||||
|
bool _preloadFlag;
|
||||||
|
|
||||||
void handleMenuResponse(uint8 selection);
|
void handleMenuResponse(uint8 selection);
|
||||||
void handleClick();
|
void handleClick();
|
||||||
|
@ -60,16 +63,19 @@ private:
|
||||||
void displayChuteAnimation();
|
void displayChuteAnimation();
|
||||||
void displayBarrelAnimation();
|
void displayBarrelAnimation();
|
||||||
void handleBootParam(int value);
|
void handleBootParam(int value);
|
||||||
|
int restartRestoreScreen();
|
||||||
public:
|
public:
|
||||||
Game();
|
Game();
|
||||||
virtual ~Game();
|
virtual ~Game();
|
||||||
|
|
||||||
static Game &getReference();
|
static Game &getReference();
|
||||||
|
|
||||||
void tick(bool fastSpeed = false);
|
void tick();
|
||||||
|
void tickCheck();
|
||||||
void nextFrame();
|
void nextFrame();
|
||||||
void execute();
|
void execute();
|
||||||
void setState(uint8 flags) { _state = flags; }
|
void setState(uint8 flags) { _state = flags; }
|
||||||
|
bool &preloadFlag() { return _preloadFlag; }
|
||||||
|
|
||||||
// Menu item support methods
|
// Menu item support methods
|
||||||
void doDebugMenu();
|
void doDebugMenu();
|
||||||
|
|
|
@ -71,6 +71,7 @@ public:
|
||||||
uint32 features() { return _features; }
|
uint32 features() { return _features; }
|
||||||
uint8 game() { return _game; }
|
uint8 game() { return _game; }
|
||||||
Disk &disk() { return *_disk; }
|
Disk &disk() { return *_disk; }
|
||||||
|
Common::Language getLanguage() { return _language; }
|
||||||
|
|
||||||
bool loadGame(uint8 slotNumber);
|
bool loadGame(uint8 slotNumber);
|
||||||
bool saveGame(uint8 slotNumber, Common::String &caption);
|
bool saveGame(uint8 slotNumber, Common::String &caption);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue