ScummVM API documentation
lure.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef LURE_LURE_H
23#define LURE_LURE_H
24
25#include "engines/engine.h"
26#include "engines/advancedDetector.h"
27
28#include "common/rect.h"
29#include "common/file.h"
30#include "common/savefile.h"
31#include "common/util.h"
32#include "common/random.h"
33
34#include "lure/disk.h"
35#include "lure/res.h"
36#include "lure/screen.h"
37#include "lure/events.h"
38#include "lure/menu.h"
39#include "lure/strings.h"
40#include "lure/room.h"
41#include "lure/fights.h"
42#include "lure/detection.h"
43
52namespace Lure {
53
54#define RandomNumberGen LureEngine::getReference().rnd()
55
56enum LureLanguage {
57 LANG_IT_ITA = 10,
58 LANG_FR_FRA = 6,
59 LANG_DE_DEU = 7,
60 LANG_ES_ESP = 17,
61 LANG_EN_ANY = 3,
62 LANG_RU_RUS = 5,
63 LANG_EN_KONAMI = 4,
64 LANG_UNKNOWN = -1
65};
66
67enum LUREActions {
68 kActionNone,
69 kActionSaveGame,
70 kActionRestoreGame,
71 kActionRestartGame,
72 kActionQuitGame,
73 kActionEscape,
74 kActionFightMoveLeft,
75 kActionFightMoveRight,
76 kActionFightCursorLeftTop,
77 kActionFightCursorLeftMiddle,
78 kActionFightCursorLeftBottom,
79 kActionFightCursorRightTop,
80 kActionFightCursorRightMiddle,
81 kActionFightCursorRightBottom,
82 kActionIndexNext,
83 kActionIndexPrevious,
84 kActionIndexSelect,
85 kActionYes,
86 kActionNo
87};
88
89struct LureGameDescription;
90
91class LureEngine : public Engine {
92private:
93 bool _initialized;
94 int _gameToLoad;
95 uint8 _saveVersion;
96 Disk *_disk;
97 Resources *_resources;
98 Screen *_screen;
99 Mouse *_mouse;
100 Events *_events;
101 Menu *_menu;
102 StringData *_strings;
103 Room *_room;
104 FightsManager *_fights;
106
107 const char *generateSaveName(int slotNumber);
108
109 const LureGameDescription *_gameDescription;
110
111public:
112 LureEngine(OSystem *system, const LureGameDescription *gameDesc);
113 ~LureEngine() override;
114 static LureEngine &getReference();
115 bool _saveLoadAllowed;
116
117 // Engine APIs
118 Common::Error init();
119 Common::Error go();
120 Common::Error run() override {
121 Common::Error err;
122 err = init();
123 if (err.getCode() != Common::kNoError)
124 return err;
125 return go();
126 }
127 bool hasFeature(EngineFeature f) const override;
128 void syncSoundSettings() override;
129 void pauseEngineIntern(bool pause) override;
130
131 Disk &disk() { return *_disk; }
132
133 Common::RandomSource &rnd() { return _rnd; }
134 int gameToLoad() { return _gameToLoad; }
135 bool loadGame(uint8 slotNumber);
136 bool saveGame(uint8 slotNumber, Common::String &caption);
137 Common::String *detectSave(int slotNumber);
138 uint8 saveVersion() { return _saveVersion; }
139
140 uint32 getFeatures() const;
141 LureLanguage getLureLanguage() const;
142 Common::Language getLanguage() const;
143 Common::Platform getPlatform() const;
144 bool isEGA() const { return (getFeatures() & GF_EGA) != 0; }
145 bool isKonami() const { return (getFeatures() & GF_KONAMI) != 0; }
146
147 Common::Error loadGameState(int slot) override {
148 return loadGame(slot) ? Common::kNoError : Common::kReadingFailed;
149 }
150 Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override {
151 Common::String s(desc);
152 return saveGame(slot, s) ? Common::kNoError : Common::kReadingFailed;
153 }
154 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
155 return _saveLoadAllowed && !Fights.isFighting();
156 }
157 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override {
158 return _saveLoadAllowed && !Fights.isFighting();
159 }
160};
161
162Common::String getSaveName(Common::InSaveFile *in);
163
164} // End of namespace Lure
165
166#endif
Definition: error.h:81
ErrorCode getCode() const
Definition: error.h:112
Definition: random.h:44
Definition: stream.h:745
Definition: str.h:59
Definition: ustr.h:57
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
Definition: disk.h:42
Definition: events.h:61
Definition: fights.h:68
Definition: lure.h:91
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Definition: lure.h:150
void pauseEngineIntern(bool pause) override
bool hasFeature(EngineFeature f) const override
Common::Error run() override
Definition: lure.h:120
Common::Error loadGameState(int slot) override
Definition: lure.h:147
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: lure.h:154
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: lure.h:157
void syncSoundSettings() override
Definition: menu.h:66
Definition: events.h:33
Definition: res.h:51
Definition: room.h:64
Definition: screen.h:35
Definition: strings.h:42
Definition: system.h:166
@ kReadingFailed
Failed to read a file (permission denied?).
Definition: error.h:63
@ kNoError
No error occurred.
Definition: error.h:48
Language
Definition: language.h:45
Platform
Definition: platform.h:93
Definition: animseq.h:27
Definition: detection.h:36