2008-08-04 11:28:57 +00: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.
|
2014-02-18 02:34:26 +01:00
|
|
|
*
|
2008-08-04 11:28:57 +00:00
|
|
|
* 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.
|
2014-02-18 02:34:26 +01:00
|
|
|
*
|
2008-08-04 11:28:57 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-05-17 18:20:01 +02:00
|
|
|
#ifndef TOLTECS_TOLTECS_H
|
|
|
|
#define TOLTECS_TOLTECS_H
|
2008-08-04 11:28:57 +00:00
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/endian.h"
|
|
|
|
#include "common/events.h"
|
2010-12-05 13:30:14 +00:00
|
|
|
#include "common/file.h"
|
2008-08-04 11:28:57 +00:00
|
|
|
#include "common/keyboard.h"
|
2010-12-05 13:30:14 +00:00
|
|
|
#include "common/random.h"
|
2011-04-30 00:09:02 +00:00
|
|
|
#include "common/textconsole.h"
|
2008-08-04 11:28:57 +00:00
|
|
|
|
|
|
|
#include "engines/engine.h"
|
|
|
|
|
2010-12-05 13:30:14 +00:00
|
|
|
#include "graphics/surface.h"
|
|
|
|
|
2013-12-07 02:28:42 +00:00
|
|
|
#include "gui/debugger.h"
|
|
|
|
|
|
|
|
#include "toltecs/console.h"
|
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
namespace Toltecs {
|
|
|
|
|
|
|
|
struct ToltecsGameDescription;
|
|
|
|
|
|
|
|
class AnimationPlayer;
|
|
|
|
class ArchiveReader;
|
|
|
|
class Input;
|
2008-09-16 07:20:44 +00:00
|
|
|
class MenuSystem;
|
|
|
|
class MoviePlayer;
|
2011-11-24 00:01:29 +02:00
|
|
|
class Music;
|
2008-08-04 11:28:57 +00:00
|
|
|
class Palette;
|
|
|
|
class ResourceCache;
|
|
|
|
class ScriptInterpreter;
|
|
|
|
class Screen;
|
|
|
|
class SegmentMap;
|
2008-10-14 21:12:52 +00:00
|
|
|
class Sound;
|
2008-08-04 11:28:57 +00:00
|
|
|
|
2010-10-31 19:38:22 +00:00
|
|
|
enum SysString {
|
|
|
|
kStrLoadingPleaseWait,
|
|
|
|
kStrWhatCanIDoForYou,
|
|
|
|
kStrLoad,
|
|
|
|
kStrSave,
|
|
|
|
kStrTextOn,
|
|
|
|
kStrTextOff,
|
|
|
|
kStrVoicesOn,
|
|
|
|
kStrVoicesOff,
|
|
|
|
kStrVolume,
|
|
|
|
kStrPlay,
|
|
|
|
kStrQuit,
|
|
|
|
kStrLoadGame,
|
|
|
|
kStrSaveGame,
|
|
|
|
kStrAdjustVolume,
|
|
|
|
kStrMaster,
|
|
|
|
kStrVoices,
|
|
|
|
kStrMusic,
|
|
|
|
kStrSoundFx,
|
|
|
|
kStrBackground,
|
|
|
|
kStrCancel,
|
|
|
|
kStrDone,
|
|
|
|
kStrAreYouSure,
|
|
|
|
kStrYes,
|
|
|
|
kStrNo,
|
|
|
|
kSysStrCount
|
|
|
|
};
|
|
|
|
|
2012-09-10 22:11:16 +03:00
|
|
|
enum MenuID {
|
|
|
|
kMenuIdNone,
|
|
|
|
kMenuIdMain,
|
|
|
|
kMenuIdSave,
|
|
|
|
kMenuIdLoad,
|
|
|
|
kMenuIdVolumes
|
|
|
|
};
|
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
class ToltecsEngine : public ::Engine {
|
|
|
|
Common::KeyState _keyPressed;
|
|
|
|
|
|
|
|
protected:
|
2020-02-05 16:27:12 +01:00
|
|
|
Common::Error run() override;
|
2008-08-04 11:28:57 +00:00
|
|
|
// void shutdown();
|
|
|
|
|
|
|
|
public:
|
|
|
|
ToltecsEngine(OSystem *syst, const ToltecsGameDescription *gameDesc);
|
|
|
|
virtual ~ToltecsEngine();
|
|
|
|
|
2020-02-04 20:03:51 -08:00
|
|
|
virtual bool hasFeature(EngineFeature f) const override;
|
2008-11-13 00:16:13 +00:00
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
Common::RandomSource *_rnd;
|
|
|
|
const ToltecsGameDescription *_gameDescription;
|
|
|
|
uint32 getFeatures() const;
|
|
|
|
Common::Language getLanguage() const;
|
2009-12-09 14:52:07 +00:00
|
|
|
const Common::String& getTargetName() const { return _targetName; }
|
2020-02-05 16:27:12 +01:00
|
|
|
void syncSoundSettings() override;
|
2008-08-04 11:28:57 +00:00
|
|
|
|
2020-02-05 16:27:12 +01:00
|
|
|
GUI::Debugger *getDebugger() override { return _console; }
|
2013-12-07 02:28:42 +00:00
|
|
|
|
2010-10-31 19:38:22 +00:00
|
|
|
void setupSysStrings();
|
2010-11-03 11:58:17 +00:00
|
|
|
void requestSavegame(int slotNum, Common::String &description);
|
|
|
|
void requestLoadgame(int slotNum);
|
2010-10-31 19:38:22 +00:00
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
void loadScene(uint resIndex);
|
|
|
|
|
|
|
|
void updateScreen();
|
2010-10-31 20:03:54 +00:00
|
|
|
void drawScreen();
|
2008-08-14 07:57:07 +00:00
|
|
|
void updateInput();
|
2008-08-04 11:28:57 +00:00
|
|
|
|
2008-08-11 12:43:00 +00:00
|
|
|
void setGuiHeight(int16 guiHeight);
|
2008-09-20 19:06:41 +00:00
|
|
|
|
|
|
|
void setCamera(int16 x, int16 y);
|
2011-04-11 11:36:53 +00:00
|
|
|
bool getCameraChanged();
|
2008-08-04 11:28:57 +00:00
|
|
|
void scrollCameraUp(int16 delta);
|
|
|
|
void scrollCameraDown(int16 delta);
|
|
|
|
void scrollCameraLeft(int16 delta);
|
|
|
|
void scrollCameraRight(int16 delta);
|
|
|
|
void updateCamera();
|
2012-09-10 22:11:16 +03:00
|
|
|
|
|
|
|
void showMenu(MenuID menuId);
|
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
void talk(int16 slotIndex, int16 slotOffset);
|
|
|
|
|
|
|
|
void walk(byte *walkData);
|
2012-09-26 04:17:31 +02:00
|
|
|
|
|
|
|
int16 findRectAtPoint(byte *rectData, int16 x, int16 y, int16 index, int16 itemSize,
|
2010-06-18 14:18:44 +00:00
|
|
|
byte *rectDataEnd);
|
2008-08-04 11:28:57 +00:00
|
|
|
|
2012-09-10 21:53:00 +03:00
|
|
|
int _cfgVoicesVolume, _cfgMusicVolume, _cfgSoundFXVolume;
|
|
|
|
bool _cfgText, _cfgVoices;
|
2008-08-04 11:28:57 +00:00
|
|
|
public:
|
2008-11-13 00:16:13 +00:00
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
AnimationPlayer *_anim;
|
|
|
|
ArchiveReader *_arc;
|
2013-01-02 20:01:00 +02:00
|
|
|
Console *_console;
|
2008-08-04 11:28:57 +00:00
|
|
|
Input *_input;
|
2008-09-16 07:20:44 +00:00
|
|
|
MenuSystem *_menuSystem;
|
|
|
|
MoviePlayer *_moviePlayer;
|
2011-11-24 00:01:29 +02:00
|
|
|
Music *_music;
|
2008-08-04 11:28:57 +00:00
|
|
|
Palette *_palette;
|
|
|
|
ResourceCache *_res;
|
|
|
|
ScriptInterpreter *_script;
|
|
|
|
Screen *_screen;
|
|
|
|
SegmentMap *_segmap;
|
2008-10-14 21:12:52 +00:00
|
|
|
Sound *_sound;
|
2008-08-04 11:28:57 +00:00
|
|
|
|
2010-10-31 19:38:22 +00:00
|
|
|
Common::String _sysStrings[kSysStrCount];
|
|
|
|
|
2010-11-03 11:58:17 +00:00
|
|
|
int _saveLoadRequested;
|
|
|
|
int _saveLoadSlot;
|
|
|
|
Common::String _saveLoadDescription;
|
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
uint _sceneResIndex;
|
|
|
|
int16 _sceneWidth, _sceneHeight;
|
2012-09-26 04:17:31 +02:00
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
int _counter01, _counter02;
|
|
|
|
bool _movieSceneFlag;
|
|
|
|
byte _flag01;
|
|
|
|
|
|
|
|
int16 _cameraX, _cameraY;
|
|
|
|
int16 _newCameraX, _newCameraY;
|
2008-08-12 12:28:28 +00:00
|
|
|
int16 _cameraHeight;
|
|
|
|
int16 _guiHeight;
|
2008-08-04 11:28:57 +00:00
|
|
|
|
|
|
|
bool _doSpeech, _doText;
|
2012-09-26 04:17:31 +02:00
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
int16 _walkSpeedY, _walkSpeedX;
|
|
|
|
|
2010-06-18 14:18:44 +00:00
|
|
|
Common::KeyState _keyState;
|
2008-08-14 07:57:07 +00:00
|
|
|
int16 _mouseX, _mouseY;
|
2010-10-31 19:38:22 +00:00
|
|
|
int16 _mouseDblClickTicks;
|
|
|
|
bool _mouseWaitForRelease;
|
2008-08-14 07:57:07 +00:00
|
|
|
byte _mouseButton;
|
|
|
|
int16 _mouseDisabled;
|
|
|
|
bool _leftButtonDown, _rightButtonDown;
|
|
|
|
|
2010-10-31 19:38:22 +00:00
|
|
|
const char *getSysString(int index) const { return _sysStrings[index].c_str(); }
|
|
|
|
|
2008-11-13 00:16:13 +00:00
|
|
|
/* Save/load */
|
|
|
|
|
|
|
|
enum kReadSaveHeaderError {
|
|
|
|
kRSHENoError = 0,
|
|
|
|
kRSHEInvalidType = 1,
|
|
|
|
kRSHEInvalidVersion = 2,
|
|
|
|
kRSHEIoError = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SaveHeader {
|
|
|
|
Common::String description;
|
|
|
|
uint32 version;
|
|
|
|
byte gameID;
|
|
|
|
uint32 flags;
|
2011-11-21 22:29:44 +02:00
|
|
|
uint32 saveDate;
|
|
|
|
uint32 saveTime;
|
|
|
|
uint32 playTime;
|
2008-11-13 00:16:13 +00:00
|
|
|
Graphics::Surface *thumbnail;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool _isSaveAllowed;
|
|
|
|
|
2020-02-05 16:27:12 +01:00
|
|
|
bool canLoadGameStateCurrently() override { return _isSaveAllowed; }
|
|
|
|
bool canSaveGameStateCurrently() override { return _isSaveAllowed; }
|
|
|
|
Common::Error loadGameState(int slot) override;
|
|
|
|
Common::Error saveGameState(int slot, const Common::String &description) override;
|
2008-11-13 00:16:13 +00:00
|
|
|
void savegame(const char *filename, const char *description);
|
|
|
|
void loadgame(const char *filename);
|
|
|
|
|
|
|
|
const char *getSavegameFilename(int num);
|
|
|
|
static Common::String getSavegameFilename(const Common::String &target, int num);
|
|
|
|
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-06 00:06:38 +02:00
|
|
|
WARN_UNUSED_RESULT static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *in, SaveHeader &header, bool skipThumbnail = true);
|
2008-11-13 00:16:13 +00:00
|
|
|
|
2008-08-04 11:28:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Toltecs
|
|
|
|
|
2016-05-17 18:20:01 +02:00
|
|
|
#endif /* TOLTECS_TOLTECS_H */
|