ScummVM API documentation
ultima_early.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 ULTIMA_SHARED_EARLY_ULTIMA_EARLY_H
23 #define ULTIMA_SHARED_EARLY_ULTIMA_EARLY_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "common/endian.h"
28 #include "common/hash-str.h"
29 #include "common/serializer.h"
30 #include "common/random.h"
31 #include "common/savefile.h"
32 #include "common/util.h"
33 #include "graphics/surface.h"
34 #include "engines/engine.h"
35 #include "ultima/detection.h"
36 
37 #include "ultima/shared/engine/events.h"
38 
39 namespace Ultima {
40 
41 struct UltimaGameDescription;
42 
43 namespace Shared {
44 
46  uint8 _version;
47  uint8 _gameId;
48  uint8 _language;
49  uint8 _videoMode;
50  Common::String _saveName;
51  Graphics::Surface *_thumbnail;
52  int _year, _month, _day;
53  int _hour, _minute;
54  int _totalFrames;
55 };
56 
57 class Events;
58 class Game;
59 class GameBase;
60 class MouseCursor;
61 class Resources;
62 
63 namespace Gfx {
64 class Screen;
65 }
66 
67 class UltimaEarlyEngine : public Engine, public EventsCallback {
68 private:
72  virtual bool initialize();
73 
77  virtual void deinitialize() {}
78 
79 private:
80  Common::RandomSource _randomSource;
81 protected:
82  const UltimaGameDescription *_gameDescription;
83 public:
84  GameBase *_game;
85  MouseCursor *_mouseCursor;
86  Gfx::Screen *_screen;
87  EventsManager *_events;
88 public:
89  UltimaEarlyEngine(OSystem *syst, const UltimaGameDescription *gameDesc);
90  ~UltimaEarlyEngine() override;
91 
95  Common::Error run() override;
96 
100  bool hasFeature(EngineFeature f) const override;
101 
105  void playGame();
106 
110  uint getRandomNumber(uint maxVal) { return _randomSource.getRandomNumber(maxVal); }
111 
115  uint getRandomNumber(uint min, uint max) {
116  return min + _randomSource.getRandomNumber(max - min);
117  }
118 
122  Graphics::Screen *getScreen() const override;
123 
128  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
129 
134  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
135 
139  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
140 
144  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
145 
149  GameId getGameId() const;
150 
155  bool isEnhanced() const;
156 
157  /*
158  * Creates a new hierarchy for the game, that contains all the logic for playing that particular game.
159  */
160  Game *createGame() const;
161 };
162 
163 } // End of namespace Shared
164 
165 extern Shared::UltimaEarlyEngine *g_vm;
166 
167 } // End of namespace Ultima
168 
169 #endif
Definition: str.h:59
Definition: surface.h:67
EngineFeature
Definition: engine.h:260
Definition: game.h:42
Definition: stream.h:77
Definition: error.h:81
Definition: random.h:44
Definition: resources.h:128
Definition: mouse_cursor.h:60
uint getRandomNumber(uint max)
Definition: atari-screen.h:58
Definition: stream.h:745
Definition: detection.h:65
Definition: screen.h:48
Definition: detection.h:27
uint getRandomNumber(uint min, uint max)
Definition: ultima_early.h:115
Definition: screen.h:58
Definition: game_base.h:53
Definition: ustr.h:57
Definition: ultima_early.h:67
Definition: events.h:139
Definition: ultima_early.h:45
Definition: system.h:163
Definition: events.h:124
uint getRandomNumber(uint maxVal)
Definition: ultima_early.h:110
Definition: engine.h:146