ScummVM API documentation
messages.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 MM1_MESSAGES_H
23#define MM1_MESSAGES_H
24
25#include "common/array.h"
26#include "common/events.h"
27#include "common/str.h"
28#include "mm/mm1/metaengine.h"
29
30namespace MM {
31namespace MM1 {
32
33class UIElement;
34
35enum TextAlign {
36 ALIGN_LEFT, ALIGN_RIGHT, ALIGN_MIDDLE
37};
38
39struct Message {};
40
41struct FocusMessage : public Message {
42 UIElement *_priorView = nullptr;
43 FocusMessage() : Message() {}
44 FocusMessage(UIElement *priorView) : Message(),
45 _priorView(priorView) {}
46};
47
48struct UnfocusMessage : public Message {};
49struct ActionMessage : public Message {
50 KeybindingAction _action;
51 ActionMessage() : Message(), _action(KEYBIND_NONE) {}
52 ActionMessage(KeybindingAction action) : Message(),
53 _action(action) {}
54};
55
56struct KeypressMessage : public Message, public Common::KeyState {
60};
61
62struct MouseMessage : public Message {
63 enum Button { MB_LEFT, MB_RIGHT, MB_MIDDLE };
64 Button _button;
65 Common::Point _pos;
66
67 MouseMessage() : Message(), _button(MB_LEFT) {}
68 MouseMessage(Button btn, const Common::Point &pos) :
69 Message(), _button(btn), _pos(pos) {}
71};
74 MouseDownMessage(Button btn, const Common::Point &pos) :
75 MouseMessage(btn, pos) {}
77 MouseMessage(type, pos) {}
78};
81 MouseUpMessage(Button btn, const Common::Point &pos) :
82 MouseMessage(btn, pos) {}
84 MouseMessage(type, pos) {}
85};
89 MouseMessage(MB_LEFT, pos) {}
90};
91
92struct GameMessage : public Message {
93 Common::String _name;
94 int _value;
95 Common::String _stringValue;
96
97 GameMessage() : Message(), _value(-1) {}
98 GameMessage(const Common::String &name) : Message(),
99 _name(name), _value(-1) {}
100 GameMessage(const Common::String &name, int value) : Message(),
101 _name(name), _value(value) {}
102 GameMessage(const Common::String &name, const Common::String &strValue,
103 int intValue = -1) :
104 Message(), _name(name), _stringValue(strValue), _value(intValue) {}
105};
106
107struct HeaderMessage : public Message {
108 Common::String _name;
109 HeaderMessage() : Message() {}
110 HeaderMessage(const Common::String &name) : Message(),
111 _name(name) {}
112};
113
114struct Line : public Common::Point {
115 Common::String _text;
116 TextAlign _align = ALIGN_LEFT;
117
118 Line() {
119 }
120 Line(const Common::String &text, TextAlign align = ALIGN_LEFT) :
121 Common::Point(-1, -1), _text(text), _align(align) {
122 }
123 Line(int x1, int y1, const Common::String &text,
124 TextAlign align = ALIGN_LEFT) :
125 Common::Point(x1, y1), _text(text), _align(align) {
126 }
127
128 size_t size() const;
129};
131
132typedef void (*YNCallback)();
133typedef void (*KeyCallback)(const Common::KeyState &keyState);
134struct InfoMessage : public Message {
135 LineArray _lines;
136 YNCallback _callback = nullptr; // Callback for timeouts and Y of Y/N queries
137 YNCallback _nCallback = nullptr; // Callback for N in Y/N queries
138 KeyCallback _keyCallback = nullptr;
139 bool _largeMessage = false;
140 bool _sound = false;
141 int _delaySeconds = 0;
142 bool _fontReduced = false;
143
144 InfoMessage();
145 InfoMessage(const Common::String &str, TextAlign align = ALIGN_LEFT);
146 InfoMessage(int x, int y, const Common::String &str, TextAlign align = ALIGN_LEFT);
147 InfoMessage(int x1, int y1, const Common::String &str1,
148 int x2, int y2, const Common::String &str2);
149
150 InfoMessage(const Common::String &str,
151 YNCallback yCallback, YNCallback nCallback = nullptr);
152 InfoMessage(int x, int y, const Common::String &str,
153 YNCallback yCallback, YNCallback nCallback = nullptr);
154 InfoMessage(int x1, int y1, const Common::String &str1,
155 int x2, int y2, const Common::String &str2,
156 YNCallback ynCallback, YNCallback nCallback = nullptr);
157
158 InfoMessage(const Common::String &str,
159 KeyCallback keyCallback);
160 InfoMessage(int x, int y, const Common::String &str,
161 KeyCallback keyCallback);
162 InfoMessage(int x1, int y1, const Common::String &str1,
163 int x2, int y2, const Common::String &str2,
164 KeyCallback keyCallback);
165};
166
167struct SoundMessage : public InfoMessage {
168public:
169 SoundMessage() : InfoMessage() { _sound = true; }
170 SoundMessage(const Common::String &str, TextAlign align = ALIGN_LEFT);
171 SoundMessage(int x, int y, const Common::String &str,
172 TextAlign align = ALIGN_LEFT) :
173 InfoMessage(x, y, str, align) { _sound = true; }
174 SoundMessage(int x1, int y1, const Common::String &str1,
175 int x2, int y2, const Common::String &str2) :
176 InfoMessage(x1, y1, str1, x2, y2, str2) { _sound = true; }
177
178 SoundMessage(const Common::String &str, YNCallback yCallback,
179 YNCallback nCallback = nullptr);
180 SoundMessage(int x, int y, const Common::String &str,
181 YNCallback yCallback, YNCallback nCallback = nullptr) :
182 InfoMessage(x, y, str, yCallback, nCallback) { _sound = true; }
183 SoundMessage(int x1, int y1, const Common::String &str1,
184 int x2, int y2, const Common::String &str2,
185 YNCallback yCallback, YNCallback nCallback = nullptr) :
186 InfoMessage(x1, y1, str1, x2, y2, str2, yCallback, nCallback) { _sound = true; }
187
188 SoundMessage(const Common::String &str, KeyCallback keyCallback);
189 SoundMessage(int x, int y, const Common::String &str,
190 KeyCallback keyCallback) :
191 InfoMessage(x, y, str, keyCallback) { _sound = true; }
192 SoundMessage(int x1, int y1, const Common::String &str1,
193 int x2, int y2, const Common::String &str2,
194 KeyCallback keyCallback) :
195 InfoMessage(x1, y1, str1, x2, y2, str2, keyCallback) { _sound = true; }
196};
197
198enum LocationType {
199 LOC_TRAINING = 0, LOC_MARKET = 1, LOC_TEMPLE = 2,
200 LOC_BLACKSMITH = 3, LOC_TAVERN = 4
201};
202
204 int _gfxNum;
205
206 DrawGraphicMessage() : Message(), _gfxNum(0) {}
207 explicit DrawGraphicMessage(int gfxNum) : Message(),
208 _gfxNum(gfxNum) {}
209};
210
211} // namespace MM1
212} // namespace MM
213
214#endif
Definition: input.h:69
Definition: str.h:59
Definition: events.h:68
EventType
Definition: events.h:49
TextAlign
Definition: font.h:48
Definition: detection.h:27
Definition: keyboard.h:294
Definition: rect.h:144
Definition: messages.h:49
Definition: messages.h:203
Definition: messages.h:41
Definition: messages.h:92
Definition: messages.h:107
Definition: messages.h:134
Definition: messages.h:56
Definition: messages.h:114
Definition: messages.h:39
Definition: messages.h:72
Definition: messages.h:62
Definition: messages.h:86
Definition: messages.h:79
Definition: messages.h:167
Definition: messages.h:48