scummvm/engines/lab/lab.h

510 lines
11 KiB
C
Raw Normal View History

2014-10-06 14:50:05 +02:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on Labyrinth of Time code with assistance of
*
* Copyright (c) 1993 Terra Nova Development
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
*
*/
#ifndef LAB_LAB_H
#define LAB_LAB_H
2014-10-06 14:50:05 +02:00
#include "common/system.h"
#include "common/random.h"
#include "common/rect.h"
2015-12-13 23:22:34 +01:00
#include "common/savefile.h"
2014-10-06 14:50:05 +02:00
#include "engines/engine.h"
2015-12-13 23:22:34 +01:00
#include "engines/savestate.h"
2014-10-06 14:50:05 +02:00
#include "lab/console.h"
#include "lab/image.h"
#include "lab/labsets.h"
2014-12-27 12:23:20 +01:00
struct ADGameDescription;
2014-10-06 14:50:05 +02:00
namespace Lab {
struct MapData;
struct Action;
struct CloseData;
2015-12-13 19:36:56 +02:00
struct Button;
struct IntuiMessage;
struct InventoryData;
struct RoomData;
struct Rule;
struct TextFont;
struct ViewData;
class Anim;
class DisplayMan;
class EventManager;
class Interface;
class Image;
class Music;
class Resource;
class SpecialLocks;
class Utils;
2015-12-13 23:22:34 +01:00
struct SaveGameHeader {
byte _version;
SaveStateDescriptor _descr;
uint16 _roomNumber;
uint16 _direction;
};
2014-12-27 12:23:20 +01:00
enum GameFeatures {
GF_LOWRES = 1 << 0,
GF_WINDOWS_TRIAL = 1 << 1
2014-12-27 12:23:20 +01:00
};
2015-12-13 19:36:56 +02:00
typedef Common::List<Button *> ButtonList;
2015-12-07 23:58:18 +01:00
struct CrumbData {
uint16 _crumbRoomNum;
uint16 _crumbDirection;
2015-12-07 23:58:18 +01:00
};
#define MAX_CRUMBS 128
typedef Common::List<Rule> RuleList;
2015-12-25 13:56:49 +02:00
typedef Common::List<Action> ActionList;
typedef Common::List<CloseData> CloseDataList;
typedef Common::List<ViewData> ViewDataList;
enum Direction {
kDirectionNorth,
kDirectionSouth,
kDirectionEast,
kDirectionWest
};
2015-12-08 20:50:11 +01:00
enum MainButton {
kButtonNone = -1,
kButtonPickup,
kButtonUse,
kButtonOpen,
kButtonClose,
kButtonLook,
kButtonInventory,
kButtonLeft,
kButtonForward,
kButtonRight,
kButtonMap
};
enum MessageClass {
kMessageLeftClick,
kMessageRightClick,
kMessageButtonUp,
kMessageRawKey
};
2014-10-06 14:50:05 +02:00
class LabEngine : public Engine {
friend class Console;
private:
bool _isCrumbWaiting;
bool _lastTooLong;
bool _lastPage;
bool _mainDisplay;
2015-12-06 17:24:25 +01:00
bool _noUpdateDiff;
bool _quitLab;
2015-11-24 23:59:30 +01:00
2015-12-13 22:55:10 +01:00
byte *_blankJournal;
int _lastWaitTOFTicks;
2015-12-06 17:24:25 +01:00
uint16 _direction;
uint16 _highPalette[20];
uint16 _journalPage;
uint16 _maxRooms;
uint16 _monitorPage;
2015-12-13 19:36:56 +02:00
uint16 _monitorButtonHeight;
uint32 _extraGameFeatures;
2015-12-06 17:24:25 +01:00
Common::String _journalText;
Common::String _journalTextTitle;
Common::String _nextFileName;
Common::String _newFileName;
Common::String _monitorTextFilename;
const CloseData *_closeDataPtr;
2015-12-13 19:36:56 +02:00
ButtonList _journalButtonList;
ButtonList _mapButtonList;
Image *_imgMap, *_imgRoom, *_imgUpArrowRoom, *_imgDownArrowRoom, *_imgBridge;
2015-12-13 20:29:58 +02:00
Image *_imgHRoom, *_imgVRoom, *_imgMaze, *_imgHugeMaze, *_imgPath;
Image *_imgMapX[4];
InventoryData *_inventory;
MapData *_maps;
Image *_monitorButton;
2015-12-13 22:55:10 +01:00
Image *_journalBackImage;
TextFont *_journalFont;
bool _introPlaying;
public:
bool _alternate;
bool _droppingCrumbs;
bool _followingCrumbs;
bool _followCrumbsFast;
bool _isCrumbTurning;
bool _isHiRes;
int _roomNum;
uint16 _highestCondition;
uint16 _manyRooms;
uint16 _numCrumbs;
uint16 _numInv;
2015-12-13 20:27:34 +02:00
uint32 _crumbTimestamp;
Common::String _curFileName;
Anim *_anim;
CrumbData _breadCrumbs[MAX_CRUMBS];
DisplayMan *_graphics;
EventManager *_event;
Interface *_interface;
2015-12-13 19:36:56 +02:00
ButtonList _invButtonList;
ButtonList _moveButtonList;
Image *_invImages[10];
Image *_moveImages[20];
LargeSet *_conditions, *_roomsFound;
Music *_music;
Resource *_resource;
RoomData *_rooms;
TextFont *_msgFont;
SpecialLocks *_specialLocks;
Utils *_utils;
Console *_console;
GUI::Debugger *getDebugger() { return _console; }
2015-11-24 23:59:30 +01:00
public:
LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
~LabEngine();
virtual Common::Error run();
void go();
const ADGameDescription *_gameDescription;
Common::Platform getPlatform() const;
uint32 getFeatures() const;
bool hasFeature(EngineFeature f) const override;
Common::String generateSaveFileName(uint slot);
void changeVolume(int delta);
uint16 getDirection() { return _direction; }
2015-12-20 02:42:52 +01:00
/**
* Returns the current picture name.
*/
Common::String getPictName(bool useClose);
uint16 getQuarters();
void setQuarters(uint16 quarters);
2015-12-27 21:12:41 +02:00
void updateEvents();
2015-11-24 23:59:30 +01:00
void waitTOF();
Common::Error loadGameState(int slot);
Common::Error saveGameState(int slot, const Common::String &desc);
bool canLoadGameStateCurrently();
bool canSaveGameStateCurrently();
bool isMainDisplay() const { return _mainDisplay; }
private:
2015-12-20 02:42:52 +01:00
/**
* Checks whether all the conditions in a condition list are met.
*/
bool checkConditions(const Common::Array<int16> &cond);
2015-12-20 02:42:52 +01:00
/**
* Decrements the current inventory number.
*/
void decIncInv(uint16 *CurInv, bool dec);
2015-12-20 02:42:52 +01:00
/**
* Processes the action list.
*/
void doActions(const ActionList &actionList);
2015-12-20 02:42:52 +01:00
/**
* Goes through the rules if an action is taken.
*/
bool doActionRule(Common::Point pos, int16 action, int16 roomNum);
2015-12-20 02:42:52 +01:00
/**
* Does the work for doActionRule.
*/
bool doActionRuleSub(int16 action, int16 roomNum, const CloseData *closePtr, bool allowDefaults);
2015-12-20 02:42:52 +01:00
/**
* Handles monitor closeups
2015-12-20 02:42:52 +01:00
*/
void handleMonitorCloseup();
2015-12-20 02:42:52 +01:00
/**
* Goes through the rules if the user tries to go forward.
*/
bool doGoForward();
2015-12-20 02:42:52 +01:00
/**
* Does the journal processing.
*/
void doJournal();
2015-12-20 02:42:52 +01:00
/**
* Goes through the rules if the user tries to go to the main view
*/
bool doMainView();
2015-12-20 02:42:52 +01:00
/**
* Does the map processing.
*/
void doMap();
2015-12-20 02:42:52 +01:00
/**
* Does what's necessary for the monitor.
*/
2015-12-20 17:21:55 +01:00
void doMonitor(const Common::String background, const Common::String textfile, bool isinteractive, Common::Rect textRect);
2015-12-20 02:42:52 +01:00
/**
* Does the things to properly set up the detective notes.
*/
void doNotes();
2015-12-20 02:42:52 +01:00
/**
* Does the work for doActionRule.
*/
bool doOperateRuleSub(int16 itemNum, int16 roomNum, const CloseData *closePtr, bool allowDefaults);
2015-12-20 02:42:52 +01:00
/**
* Goes through the rules if the user tries to operate an item on an object.
*/
bool doOperateRule(Common::Point pos, int16 ItemNum);
2015-12-20 02:42:52 +01:00
/**
* Goes through the rules if the user tries to turn.
*/
bool doTurn(uint16 from, uint16 to);
2015-12-20 02:42:52 +01:00
/**
* If the user hits the "Use" button; things that can get used on themselves.
*/
bool doUse(uint16 curInv);
2015-12-20 02:42:52 +01:00
/**
* Does the things to properly set up the old west newspaper. Assumes that
* OpenHiRes already called.
*/
void doWestPaper();
2015-12-20 02:42:52 +01:00
/**
* Draws the current direction to the screen.
*/
void drawDirection(const CloseData *closePtr);
2015-12-20 02:42:52 +01:00
/**
* Draws the journal from page x.
*/
void drawJournal(uint16 wipenum, bool needFade);
2015-12-20 02:42:52 +01:00
/**
* Draws the text to the back journal screen to the appropriate Page number
*/
void drawJournalText();
2015-12-20 02:42:52 +01:00
/**
* Draws the map
*/
void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeIn);
2015-12-20 02:42:52 +01:00
/**
* Draws the text for the monitor.
*/
2015-12-23 21:51:39 +01:00
void drawMonText(const char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive);
2015-12-20 02:42:52 +01:00
/**
* Draws a room map.
*/
void drawRoomMap(uint16 curRoom, bool drawMarkFl);
2015-12-20 02:42:52 +01:00
/**
* Draws the message for the room.
*/
void drawRoomMessage(uint16 curInv, const CloseData *closePtr);
void drawStaticMessage(byte index);
2015-12-20 02:42:52 +01:00
/**
* Eats all the available messages.
*/
void eatMessages();
2015-12-20 02:42:52 +01:00
/**
* Goes through the list of closeups to find a match.
* @note Known bug here. If there are two objects that have closeups, and
* some of the closeups have the same hit boxes, then this returns the first
* occurrence of the object with the same hit box.
*/
const CloseData *findClosePtrMatch(const CloseData *closePtr, const CloseDataList &list);
2015-12-20 02:42:52 +01:00
/**
* Checks if a floor has been visited.
*/
bool floorVisited(uint16 floorNum);
2015-12-20 02:42:52 +01:00
/**
* New code to allow quick(er) return navigation in game.
*/
MainButton followCrumbs();
void freeMapData();
void freeScreens();
bool processEvent(MessageClass tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
2015-12-13 19:36:56 +02:00
uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
2015-12-20 02:42:52 +01:00
/**
* Gets the current inventory name.
*/
Common::String getInvName(uint16 curInv);
2015-12-20 02:42:52 +01:00
/**
* Returns the floor to show when the down arrow is pressed
* @note The original did not show all the visited floors, but we do
*/
uint16 getLowerFloor(uint16 floorNum);
2015-12-20 02:42:52 +01:00
/**
* Gets an object, if any, from the user's click on the screen.
*/
const CloseData *getObject(Common::Point pos, const CloseData *closePtr);
2015-12-20 02:42:52 +01:00
/**
* Returns the floor to show when the up arrow is pressed
* @note The original did not show all the visited floors, but we do
*/
uint16 getUpperFloor(uint16 floorNum);
2015-12-20 02:42:52 +01:00
/**
* Gets the current ViewDataPointer.
*/
ViewData *getViewData(uint16 roomNum, uint16 direction);
2015-12-20 02:42:52 +01:00
/**
* Turns the interface off.
*/
void interfaceOff();
2015-12-20 02:42:52 +01:00
/**
* Turns the interface on.
*/
void interfaceOn();
2015-12-20 02:42:52 +01:00
/**
* Loads in the data for the journal.
*/
void loadJournalData();
2015-12-20 02:42:52 +01:00
/**
* Loads in the map data.
*/
void loadMapData();
2015-12-20 02:42:52 +01:00
/**
* The main game loop.
*/
void mainGameLoop();
void showLab2Teaser();
2015-12-20 02:42:52 +01:00
/**
* Permanently flips the imagery of a button.
*/
2015-12-16 23:27:32 +02:00
void perFlipButton(uint16 buttonId);
2015-12-20 02:42:52 +01:00
/**
* process a arrow button movement.
*/
uint16 processArrow(uint16 curDirection, uint16 arrow);
2015-12-20 02:42:52 +01:00
/**
* Processes user input.
*/
void processJournal();
2015-12-20 02:42:52 +01:00
/**
* Processes the map.
*/
void processMap(uint16 curRoom);
2015-12-20 02:42:52 +01:00
/**
* Processes user input.
*/
void processMonitor(const Common::String &ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect);
2015-12-20 02:42:52 +01:00
/**
* Figures out what a room's coordinates should be.
*/
Common::Rect roomCoords(uint16 curRoom);
bool saveRestoreGame();
2015-12-20 02:42:52 +01:00
/**
* Sets the current close up data.
*/
void setCurrentClose(Common::Point pos, const CloseData **closePtrList, bool useAbsoluteCoords, bool next=false);
2015-12-20 02:42:52 +01:00
/**
* Takes the currently selected item.
*/
bool takeItem(Common::Point pos);
2015-12-20 02:42:52 +01:00
/**
* Does the turn page wipe.
*/
void turnPage(bool fromLeft);
bool processKey(IntuiMessage *curMsg, uint32 msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code);
void processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
void processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonId, uint16 &actionMode);
void performAction(uint16 actionMode, Common::Point curPos, uint16 &curInv);
2015-12-13 23:22:34 +01:00
/**
* Writes the game out to disk.
*/
2015-12-20 17:21:55 +01:00
bool saveGame(int slot, const Common::String desc);
/**
* Reads the game from disk.
*/
2015-12-13 23:22:34 +01:00
bool loadGame(int slot);
void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
void handleTrialWarning();
2014-10-06 14:50:05 +02:00
};
WARN_UNUSED_RESULT bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header, bool skipThumbnail = true);
2014-12-25 19:13:52 +01:00
2014-10-06 14:50:05 +02:00
} // End of namespace Lab
#endif // LAB_LAB_H