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
32namespace Ultima {
33namespace Shared {
34
35class UltimaEngine;
36class GameState;
37
38namespace Gfx {
39class Font;
40class Popup;
41class TextCursor;
42class TextInput;
43class VisualItem;
44} // End of namespace Gfx
45
46namespace Maps {
47class Map;
48} // End of namespace Maps
49
53class GameBase : public TreeItem, public EventTarget {
54private:
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);
71protected:
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;
80public:
81 Gfx::TextCursor *_textCursor;
82 uint _videoMode;
83public:
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
128
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(Common::U32String *msg = nullptr) { return true; }
188
192 virtual bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) { return false; }
193
198};
199
200} // End of namespace Shared
201} // End of namespace Ultima
202
203#endif
Definition: serializer.h:80
Definition: str.h:59
Definition: ustr.h:57
Definition: events.h:56
Definition: game_base.h:53
void mouseMove(const Point &mousePos) override
virtual bool isVGA() const
Definition: game_base.h:117
virtual bool canLoadGameStateCurrently(Common::U32String *msg=nullptr)
Definition: game_base.h:187
virtual bool canSaveGameStateCurrently(Common::U32String *msg=nullptr)
Definition: game_base.h:192
void setFont(Gfx::Font *font)
uint getRandomNumber(uint max)
void setView(Gfx::VisualItem *view)
virtual Maps::Map * getMap() const
Definition: game_base.h:162
void setPopup(Gfx::Popup *popup)
void setView(const Common::String &viewName)
void sleep(uint time)
Gfx::VisualItem * getView() const
Definition: game_base.h:147
Gfx::Font * getFont() const
Definition: game_base.h:157
uint getRandomNumber(uint min, uint max)
virtual void synchronize(Common::Serializer &s)
uint32 getMillis() const
virtual void starting(bool isLoading)
Definition: game_base.h:112
void onIdle() override
Definition: font.h:34
Definition: popup.h:38
Definition: text_cursor.h:35
Definition: visual_item.h:39
Definition: input_handler.h:33
Definition: input_translator.h:33
Definition: map.h:46
Definition: tree_item.h:50
Definition: keyboard.h:294
Definition: rect.h:144