ScummVM API documentation
game_base.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_GAME_BASE_H
23 #define ULTIMA_SHARED_EARLY_GAME_BASE_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "common/serializer.h"
28 #include "ultima/shared/engine/events.h"
29 #include "ultima/shared/engine/input_handler.h"
30 #include "ultima/shared/engine/input_translator.h"
31 
32 namespace Ultima {
33 namespace Shared {
34 
35 class UltimaEngine;
36 class GameState;
37 
38 namespace Gfx {
39 class Font;
40 class Popup;
41 class TextCursor;
42 class TextInput;
43 class VisualItem;
44 } // End of namespace Gfx
45 
46 namespace Maps {
47 class Map;
48 } // End of namespace Maps
49 
53 class GameBase : public TreeItem, public EventTarget {
54 private:
59  int getSavegameSlot();
60 
61  void leftButtonDoubleClick(const Point &mousePos) override;
62  void middleButtonDoubleClick(const Point &mousePos) override;
63  void rightButtonDoubleClick(const Point &mousePos);
64 
68  bool isMouseControlEnabled() const { return true; }
69 
70  void changeView(const Common::String &name);
71 protected:
72  uint32 _priorLeftDownTime;
73  uint32 _priorMiddleDownTime;
74  uint32 _priorRightDownTime;
75  Gfx::VisualItem *_currentView;
76  Gfx::Popup *_pendingPopup;
77  InputHandler _inputHandler;
78  InputTranslator _inputTranslator;
79  Gfx::Font *_font;
80 public:
81  Gfx::TextCursor *_textCursor;
82  uint _videoMode;
83 public:
87  GameBase();
88 
92  ~GameBase() override;
93 
97  void onIdle() override;
98 
99  void mouseMove(const Point &mousePos) override;
100  void leftButtonDown(const Point &mousePos) override;
101  void leftButtonUp(const Point &mousePos) override;
102  void middleButtonDown(const Point &mousePos) override;
103  void middleButtonUp(const Point &mousePos) override;
104  void rightButtonDown(const Point &mousePos) override;
105  void rightButtonUp(const Point &mousePos) override;
106  void mouseWheel(const Point &mousePos, bool wheelUp) override;
107  void keyDown(Common::KeyState keyState) override;
108 
112  virtual void starting(bool isLoading) {}
113 
117  virtual bool isVGA() const { return false; }
118 
122  void update();
123 
127  void mouseChanged();
128 
132  void setView(Gfx::VisualItem *view);
133 
137  void setView(const Common::String &viewName);
138 
142  void setPopup(Gfx::Popup *popup);
143 
147  Gfx::VisualItem *getView() const { return _currentView; }
148 
152  void setFont(Gfx::Font *font);
153 
157  Gfx::Font *getFont() const { return _font; }
158 
162  virtual Maps::Map *getMap() const { return nullptr; }
163 
167  uint getRandomNumber(uint max);
168 
172  uint getRandomNumber(uint min, uint max);
173 
177  void sleep(uint time);
178 
182  uint32 getMillis() const;
183 
187  virtual bool canLoadGameStateCurrently() { return true; }
188 
192  virtual bool canSaveGameStateCurrently() { return false; }
193 
197  virtual void synchronize(Common::Serializer &s);
198 };
199 
200 } // End of namespace Shared
201 } // End of namespace Ultima
202 
203 #endif
Definition: input_translator.h:33
Definition: map.h:46
Definition: str.h:59
Definition: tree_item.h:50
virtual Maps::Map * getMap() const
Definition: game_base.h:162
virtual bool canLoadGameStateCurrently()
Definition: game_base.h:187
Gfx::VisualItem * getView() const
Definition: game_base.h:147
Definition: visual_item.h:39
virtual bool canSaveGameStateCurrently()
Definition: game_base.h:192
Definition: serializer.h:79
Definition: input_handler.h:33
Definition: detection.h:27
virtual void starting(bool isLoading)
Definition: game_base.h:112
Definition: events.h:56
Definition: game_base.h:53
Definition: text_cursor.h:35
Definition: rect.h:45
Definition: font.h:34
Gfx::Font * getFont() const
Definition: game_base.h:157
Definition: keyboard.h:294
Definition: popup.h:38
virtual bool isVGA() const
Definition: game_base.h:117