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 
52 namespace Lure {
53 
54 #define RandomNumberGen LureEngine::getReference().rnd()
55 
56 enum 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 = 3, // English data has been overridden
63  LANG_EN_KONAMI = 4,
64  LANG_UNKNOWN = -1
65 };
66 
67 struct LureGameDescription;
68 
69 class LureEngine : public Engine {
70 private:
71  bool _initialized;
72  int _gameToLoad;
73  uint8 _saveVersion;
74  Disk *_disk;
75  Resources *_resources;
76  Screen *_screen;
77  Mouse *_mouse;
78  Events *_events;
79  Menu *_menu;
80  StringData *_strings;
81  Room *_room;
82  FightsManager *_fights;
84 
85  const char *generateSaveName(int slotNumber);
86 
87  const LureGameDescription *_gameDescription;
88 
89 public:
90  LureEngine(OSystem *system, const LureGameDescription *gameDesc);
91  ~LureEngine() override;
92  static LureEngine &getReference();
93  bool _saveLoadAllowed;
94 
95  // Engine APIs
96  Common::Error init();
97  Common::Error go();
98  Common::Error run() override {
99  Common::Error err;
100  err = init();
101  if (err.getCode() != Common::kNoError)
102  return err;
103  return go();
104  }
105  bool hasFeature(EngineFeature f) const override;
106  void syncSoundSettings() override;
107  void pauseEngineIntern(bool pause) override;
108 
109  Disk &disk() { return *_disk; }
110 
111  Common::RandomSource &rnd() { return _rnd; }
112  int gameToLoad() { return _gameToLoad; }
113  bool loadGame(uint8 slotNumber);
114  bool saveGame(uint8 slotNumber, Common::String &caption);
115  Common::String *detectSave(int slotNumber);
116  uint8 saveVersion() { return _saveVersion; }
117 
118  uint32 getFeatures() const;
119  LureLanguage getLureLanguage() const;
120  Common::Language getLanguage() const;
121  Common::Platform getPlatform() const;
122  bool isEGA() const { return (getFeatures() & GF_EGA) != 0; }
123  bool isKonami() const { return (getFeatures() & GF_KONAMI) != 0; }
124 
125  Common::Error loadGameState(int slot) override {
126  return loadGame(slot) ? Common::kNoError : Common::kReadingFailed;
127  }
128  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override {
129  Common::String s(desc);
130  return saveGame(slot, s) ? Common::kNoError : Common::kReadingFailed;
131  }
132  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
133  return _saveLoadAllowed && !Fights.isFighting();
134  }
135  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override {
136  return _saveLoadAllowed && !Fights.isFighting();
137  }
138 };
139 
140 Common::String getSaveName(Common::InSaveFile *in);
141 
142 } // End of namespace Lure
143 
144 #endif
Definition: events.h:33
Definition: str.h:59
Failed to read a file (permission denied?).
Definition: error.h:62
EngineFeature
Definition: engine.h:250
Definition: error.h:84
ErrorCode getCode() const
Definition: error.h:115
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Definition: lure.h:128
Definition: random.h:44
void pauseEngineIntern(bool pause) override
No error occurred.
Definition: error.h:48
Definition: screen.h:35
Definition: fights.h:68
Definition: disk.h:42
Definition: stream.h:745
Definition: menu.h:66
Definition: ustr.h:57
Definition: lure.h:69
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: lure.h:135
void syncSoundSettings() override
Common::Error loadGameState(int slot) override
Definition: lure.h:125
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: lure.h:132
Definition: strings.h:42
Common::Error run() override
Definition: lure.h:98
Definition: res.h:51
Definition: detection.h:36
Definition: animseq.h:27
Definition: system.h:167
Definition: events.h:61
Definition: engine.h:143
bool hasFeature(EngineFeature f) const override
Platform
Definition: platform.h:46
Language
Definition: language.h:45
Definition: room.h:64