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