ScummVM API documentation
game.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 ULTIMA3_VIEWS_GAME_H
23#define ULTIMA3_VIEWS_GAME_H
24
25#include "common/ptr.h"
26#include "ultima/shared/engine/view.h"
27#include "ultima/ultima3/views/interactions/interaction.h"
28
29namespace Ultima {
30namespace Ultima3 {
31namespace Views {
32
33using namespace Graphics::Views;
34
35constexpr int FRAME_COLS = 40;
36
43class Game : public Shared::View {
44private:
45 int _idleFrames = 0;
46 bool _wasInteracting = false;
47 int _windCounter = 1;
49
50 void drawFrame(GfxSurface &s);
51 void drawPartyStatus(GfxSurface &s);
52 void drawWind(GfxSurface &s);
53 void invertRect(GfxSurface &s, const Common::Rect &r);
54
58 void updateWind();
59
63 void updateMusic();
64
65protected:
66 bool _gameOver = false;
67
71 virtual void drawViewport(GfxSurface &s) = 0;
72
76 virtual void drawLabels(GfxSurface &s);
77
82
86 bool hasInteraction() const {
87 return _interaction.get() != nullptr;
88 }
89
93 virtual void idleTimeout() = 0;
94
98 virtual void endTurn() = 0;
99
103 virtual byte musicLocation() const;
104
108 virtual void processFrame() {}
109
113 virtual bool isWaiting() const {
114 return true;
115 }
116
122 virtual bool handleCommand(const KeypressMessage &msg);
123
128
133 void commandFailed(const char *text, byte sound = 0xFE);
134
138 void startGame();
139
144
150
151public:
156 _interaction.reset();
157 }
158
159 Game(const Common::String &name) : View(name) {}
160 ~Game() override {}
161
165 bool isEndgame() const {
166 return _interaction && _interaction->isEndgame();
167 }
168
169 bool msgFocus(const FocusMessage &msg) override;
170 bool msgKeypress(const KeypressMessage &msg) override;
171 void draw() override;
172 void timeout() override;
173};
174
175} // namespace Views
176} // namespace Ultima3
177} // namespace Ultima
178
179#endif
Definition: ptr.h:572
void reset(PointerType o=nullptr)
Definition: ptr.h:607
PointerType get() const
Definition: ptr.h:637
Definition: str.h:59
Definition: gfx_surface.h:34
Definition: view.h:41
Definition: view.h:35
Definition: game.h:43
virtual bool handleCommand(const KeypressMessage &msg)
void drawMoons(GfxSurface &s)
virtual bool isWaiting() const
Definition: game.h:113
virtual void processFrame()
Definition: game.h:108
void cancelInteraction()
Definition: game.h:155
bool isEndgame() const
Definition: game.h:165
void startInteraction(Interactions::Interaction *interaction)
virtual byte musicLocation() const
bool hasInteraction() const
Definition: game.h:86
virtual void drawLabels(GfxSurface &s)
virtual void idleTimeout()=0
virtual void drawViewport(GfxSurface &s)=0
void commandFailed(const char *text, byte sound=0xFE)
Definition: rect.h:536
Definition: messages.h:42
Definition: messages.h:54