2014-12-23 04:49:35 +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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef XEEN_XEEN_H
|
|
|
|
#define XEEN_XEEN_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/error.h"
|
|
|
|
#include "common/random.h"
|
|
|
|
#include "common/serializer.h"
|
|
|
|
#include "common/util.h"
|
|
|
|
#include "engines/engine.h"
|
2015-01-13 05:16:26 +00:00
|
|
|
#include "xeen/combat.h"
|
2014-12-23 04:49:35 +00:00
|
|
|
#include "xeen/debugger.h"
|
2018-03-04 23:12:09 +00:00
|
|
|
#include "xeen/dialogs/dialogs.h"
|
2014-12-25 08:29:38 +00:00
|
|
|
#include "xeen/events.h"
|
2015-01-05 13:11:16 +00:00
|
|
|
#include "xeen/files.h"
|
2015-01-03 13:19:14 +00:00
|
|
|
#include "xeen/interface.h"
|
2017-12-13 01:29:47 +00:00
|
|
|
#include "xeen/locations.h"
|
2015-01-05 13:11:16 +00:00
|
|
|
#include "xeen/map.h"
|
2015-01-02 22:14:57 +00:00
|
|
|
#include "xeen/party.h"
|
2018-04-09 23:33:31 +00:00
|
|
|
#include "xeen/patcher.h"
|
2015-02-06 01:17:16 +00:00
|
|
|
#include "xeen/resources.h"
|
2015-01-02 21:01:41 +00:00
|
|
|
#include "xeen/saves.h"
|
2014-12-25 08:29:38 +00:00
|
|
|
#include "xeen/screen.h"
|
2015-01-19 16:32:57 +00:00
|
|
|
#include "xeen/scripts.h"
|
2014-12-26 03:37:20 +00:00
|
|
|
#include "xeen/sound.h"
|
2015-01-26 02:19:59 +00:00
|
|
|
#include "xeen/spells.h"
|
2017-11-30 01:24:03 +00:00
|
|
|
#include "xeen/window.h"
|
2014-12-23 04:49:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the namespace of the Xeen engine.
|
|
|
|
*
|
|
|
|
* Status of this engine: In Development
|
|
|
|
*
|
|
|
|
* Games using this engine:
|
|
|
|
* - Might & Magic 4: Clouds of Xeen
|
|
|
|
* - Might & Magic 5: Dark Side of Xeen
|
|
|
|
* - Might & Magic: World of Xeen
|
|
|
|
* - Might & Magic: Swords of Xeen
|
|
|
|
*/
|
|
|
|
namespace Xeen {
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GType_Clouds = 1,
|
2014-12-25 06:02:51 +00:00
|
|
|
GType_DarkSide = 2,
|
|
|
|
GType_WorldOfXeen = 3,
|
2014-12-23 04:49:35 +00:00
|
|
|
GType_Swords = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
enum XeenDebugChannels {
|
|
|
|
kDebugPath = 1 << 0,
|
|
|
|
kDebugScripts = 1 << 1,
|
|
|
|
kDebugGraphics = 1 << 2,
|
|
|
|
kDebugSound = 1 << 3
|
|
|
|
};
|
|
|
|
|
2014-12-31 08:50:24 +00:00
|
|
|
enum Mode {
|
2015-01-24 01:44:02 +00:00
|
|
|
MODE_FF = -1,
|
2018-03-13 22:17:02 +00:00
|
|
|
MODE_STARTUP = 0,
|
2018-04-15 13:51:18 +00:00
|
|
|
MODE_INTERACTIVE = 1,
|
2015-02-08 02:17:31 +00:00
|
|
|
MODE_COMBAT = 2,
|
2015-01-04 00:08:30 +00:00
|
|
|
MODE_3 = 3,
|
|
|
|
MODE_4 = 4,
|
2015-02-08 02:17:31 +00:00
|
|
|
MODE_SLEEPING = 5,
|
2015-01-04 00:08:30 +00:00
|
|
|
MODE_6 = 6,
|
|
|
|
MODE_7 = 7,
|
|
|
|
MODE_8 = 8,
|
2018-04-15 13:51:18 +00:00
|
|
|
MODE_SCRIPT_IN_PROGRESS = 9,
|
2015-02-01 16:56:08 +00:00
|
|
|
MODE_CHARACTER_INFO = 10,
|
2018-04-15 13:51:18 +00:00
|
|
|
MODE_INTERACTIVE2 = 12,
|
2015-03-04 13:49:05 +00:00
|
|
|
MODE_DIALOG_123 = 13,
|
2018-04-15 13:51:18 +00:00
|
|
|
MODE_INTERACTIVE7 = 17,
|
2015-02-14 04:20:23 +00:00
|
|
|
MODE_86 = 86
|
2014-12-31 08:50:24 +00:00
|
|
|
};
|
|
|
|
|
2018-02-27 00:15:00 +00:00
|
|
|
enum GameMode {
|
|
|
|
GMODE_NONE = 0,
|
|
|
|
GMODE_STARTUP = 1,
|
|
|
|
GMODE_MENU = 2,
|
|
|
|
GMODE_PLAY_GAME = 3,
|
|
|
|
GMODE_QUIT = 4
|
2018-01-28 01:00:24 +00:00
|
|
|
};
|
|
|
|
|
2014-12-23 04:49:35 +00:00
|
|
|
struct XeenGameDescription;
|
|
|
|
|
|
|
|
#define XEEN_SAVEGAME_VERSION 1
|
|
|
|
|
2015-01-03 13:19:14 +00:00
|
|
|
class XeenEngine : public Engine {
|
2018-03-26 03:12:14 +00:00
|
|
|
/**
|
|
|
|
* Container to a set of options newly introduced under ScummVM
|
|
|
|
*/
|
|
|
|
struct ExtendedOptions {
|
|
|
|
bool _showItemCosts;
|
2018-04-14 02:56:37 +00:00
|
|
|
bool _durableArmor;
|
2018-03-26 03:12:14 +00:00
|
|
|
|
2018-04-14 02:56:37 +00:00
|
|
|
ExtendedOptions() : _showItemCosts(false), _durableArmor(false) {}
|
2018-03-26 03:12:14 +00:00
|
|
|
};
|
2014-12-23 04:49:35 +00:00
|
|
|
private:
|
|
|
|
const XeenGameDescription *_gameDescription;
|
|
|
|
Common::RandomSource _randomSource;
|
2018-01-14 22:59:43 +00:00
|
|
|
private:
|
2018-02-20 23:50:17 +00:00
|
|
|
/**
|
|
|
|
* Initializes all the engine sub-objects
|
|
|
|
*/
|
|
|
|
bool initialize();
|
2018-01-14 22:59:43 +00:00
|
|
|
|
2018-03-26 03:12:14 +00:00
|
|
|
/**
|
|
|
|
* Load settings
|
|
|
|
*/
|
|
|
|
void loadSettings();
|
|
|
|
|
2018-01-14 22:59:43 +00:00
|
|
|
// Engine APIs
|
|
|
|
virtual Common::Error run();
|
|
|
|
virtual bool hasFeature(EngineFeature f) const;
|
2015-01-02 05:15:08 +00:00
|
|
|
|
2018-02-27 00:15:00 +00:00
|
|
|
/**
|
|
|
|
* Outer gameplay loop responsible for dispatching control to game-specific
|
|
|
|
* intros, main menus, or to play the actual game
|
|
|
|
*/
|
|
|
|
void outerGameLoop();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inner game loop
|
|
|
|
*/
|
|
|
|
void gameLoop();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plays the actual game
|
|
|
|
*/
|
2015-01-05 13:11:16 +00:00
|
|
|
void play();
|
|
|
|
|
2018-02-27 00:15:00 +00:00
|
|
|
/**
|
|
|
|
* Shows a please wait dialog
|
|
|
|
*/
|
2015-01-05 13:11:16 +00:00
|
|
|
void pleaseWait();
|
2018-01-14 22:59:43 +00:00
|
|
|
protected:
|
|
|
|
int _loadSaveSlot;
|
2014-12-25 06:02:51 +00:00
|
|
|
protected:
|
2016-09-23 17:11:29 +00:00
|
|
|
/**
|
2018-02-27 00:15:00 +00:00
|
|
|
* Show the starting sequence/intro
|
|
|
|
*/
|
|
|
|
virtual void showStartup() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the startup menu
|
2016-09-23 17:11:29 +00:00
|
|
|
*/
|
2018-02-27 00:15:00 +00:00
|
|
|
virtual void showMainMenu() = 0;
|
2015-11-21 01:11:23 +00:00
|
|
|
|
2014-12-23 04:49:35 +00:00
|
|
|
/**
|
2016-08-28 21:52:56 +00:00
|
|
|
* Play the game
|
|
|
|
*/
|
2014-12-25 06:02:51 +00:00
|
|
|
virtual void playGame();
|
2018-01-19 02:29:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Death cutscene
|
|
|
|
*/
|
|
|
|
virtual void death() = 0;
|
2014-12-23 04:49:35 +00:00
|
|
|
public:
|
2015-01-13 05:16:26 +00:00
|
|
|
Combat *_combat;
|
2014-12-23 04:49:35 +00:00
|
|
|
Debugger *_debugger;
|
2014-12-25 08:29:38 +00:00
|
|
|
EventsManager *_events;
|
2015-01-05 13:11:16 +00:00
|
|
|
FileManager *_files;
|
2015-01-03 13:19:14 +00:00
|
|
|
Interface *_interface;
|
2017-12-13 01:29:47 +00:00
|
|
|
LocationManager *_locations;
|
2015-01-05 13:11:16 +00:00
|
|
|
Map *_map;
|
2015-01-19 16:32:57 +00:00
|
|
|
Party *_party;
|
2018-04-09 23:33:31 +00:00
|
|
|
Patcher *_patcher;
|
2015-02-06 01:17:16 +00:00
|
|
|
Resources *_resources;
|
2015-01-02 21:01:41 +00:00
|
|
|
SavesManager *_saves;
|
2014-12-25 08:29:38 +00:00
|
|
|
Screen *_screen;
|
2015-01-19 16:32:57 +00:00
|
|
|
Scripts *_scripts;
|
2016-09-13 00:10:37 +00:00
|
|
|
Sound *_sound;
|
2015-01-26 02:19:59 +00:00
|
|
|
Spells *_spells;
|
2017-11-30 01:24:03 +00:00
|
|
|
Windows *_windows;
|
2014-12-31 08:50:24 +00:00
|
|
|
Mode _mode;
|
2018-02-27 00:15:00 +00:00
|
|
|
GameMode _gameMode;
|
2015-01-03 13:19:14 +00:00
|
|
|
bool _noDirectionSense;
|
2015-01-24 01:44:02 +00:00
|
|
|
bool _startupWindowActive;
|
2016-09-20 03:01:32 +00:00
|
|
|
uint _endingScore;
|
2018-03-05 03:21:51 +00:00
|
|
|
bool _gameWon[3];
|
|
|
|
uint _finalScore;
|
2018-03-26 03:12:14 +00:00
|
|
|
ExtendedOptions _extOptions;
|
2014-12-23 04:49:35 +00:00
|
|
|
public:
|
|
|
|
XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc);
|
|
|
|
virtual ~XeenEngine();
|
|
|
|
|
|
|
|
uint32 getFeatures() const;
|
|
|
|
Common::Language getLanguage() const;
|
|
|
|
Common::Platform getPlatform() const;
|
|
|
|
uint16 getVersion() const;
|
|
|
|
uint32 getGameID() const;
|
|
|
|
uint32 getGameFeatures() const;
|
|
|
|
|
|
|
|
int getRandomNumber(int maxNumber);
|
|
|
|
|
2015-01-23 03:05:36 +00:00
|
|
|
int getRandomNumber(int minNumber, int maxNumber);
|
|
|
|
|
2018-02-20 23:50:17 +00:00
|
|
|
/**
|
|
|
|
* Displays an error message in a GUI dialog
|
|
|
|
*/
|
|
|
|
void GUIError(const char *msg, ...) GCC_PRINTF(2, 3);
|
|
|
|
|
2018-02-12 02:16:23 +00:00
|
|
|
/**
|
2018-04-07 19:53:27 +00:00
|
|
|
* Returns true if the game should be exited (either quitting, exiting to the main menu, or loading a savegame)
|
2018-02-12 02:16:23 +00:00
|
|
|
*/
|
2018-04-07 19:53:27 +00:00
|
|
|
bool shouldExit() const { return _gameMode != GMODE_NONE || isLoadPending() || shouldQuit(); }
|
2018-02-12 02:16:23 +00:00
|
|
|
|
2018-03-21 02:06:22 +00:00
|
|
|
/**
|
|
|
|
* Returns true if a savegame load is pending
|
|
|
|
*/
|
|
|
|
bool isLoadPending() const { return _loadSaveSlot != -1; }
|
|
|
|
|
2014-12-23 04:49:35 +00:00
|
|
|
/**
|
|
|
|
* Load a savegame
|
|
|
|
*/
|
|
|
|
virtual Common::Error loadGameState(int slot);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save the game
|
|
|
|
*/
|
|
|
|
virtual Common::Error saveGameState(int slot, const Common::String &desc);
|
|
|
|
|
2018-01-28 16:53:11 +00:00
|
|
|
/**
|
|
|
|
* Updates sound settings
|
|
|
|
*/
|
|
|
|
virtual void syncSoundSettings();
|
|
|
|
|
2014-12-23 04:49:35 +00:00
|
|
|
/**
|
|
|
|
* Returns true if a savegame can currently be loaded
|
|
|
|
*/
|
2018-01-30 00:10:38 +00:00
|
|
|
virtual bool canLoadGameStateCurrently();
|
2014-12-23 04:49:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the game can currently be saved
|
|
|
|
*/
|
2018-01-30 00:10:38 +00:00
|
|
|
virtual bool canSaveGameStateCurrently();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a cutscene
|
2018-02-02 01:15:09 +00:00
|
|
|
* @param name Name of cutscene
|
|
|
|
* @param status For World of Xeen, Goober status
|
|
|
|
* @param score Final score
|
2018-01-30 00:10:38 +00:00
|
|
|
*/
|
2018-02-02 01:15:09 +00:00
|
|
|
virtual void showCutscene(const Common::String &name, int status, uint score) {}
|
2014-12-23 04:49:35 +00:00
|
|
|
|
2018-02-14 02:33:02 +00:00
|
|
|
/**
|
|
|
|
* Dream sequence
|
|
|
|
*/
|
|
|
|
virtual void dream() = 0;
|
|
|
|
|
2015-01-27 02:35:50 +00:00
|
|
|
static Common::String printMil(uint value);
|
|
|
|
|
|
|
|
static Common::String printK(uint value);
|
2015-03-01 15:41:11 +00:00
|
|
|
|
|
|
|
static Common::String printK2(uint value);
|
2018-03-04 03:15:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves engine settings
|
|
|
|
*/
|
|
|
|
void saveSettings();
|
2014-12-23 04:49:35 +00:00
|
|
|
};
|
|
|
|
|
2016-09-18 00:06:43 +00:00
|
|
|
extern XeenEngine *g_vm;
|
|
|
|
|
2014-12-23 04:49:35 +00:00
|
|
|
} // End of namespace Xeen
|
|
|
|
|
|
|
|
#endif /* XEEN_XEEN_H */
|