File: messages.h

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (209 lines) | stat: -rw-r--r-- 6,905 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef MM1_MESSAGES_H
#define MM1_MESSAGES_H

#include "common/array.h"
#include "common/events.h"
#include "common/str.h"
#include "mm/mm1/metaengine.h"

namespace MM {
namespace MM1 {

class UIElement;

enum TextAlign {
	ALIGN_LEFT, ALIGN_RIGHT, ALIGN_MIDDLE
};

struct Message {};

struct FocusMessage : public Message {
	UIElement *_priorView = nullptr;
	FocusMessage() : Message() {}
	FocusMessage(UIElement *priorView) : Message(),
		_priorView(priorView) {}
};

struct UnfocusMessage : public Message {};
struct ActionMessage : public Message {
	KeybindingAction _action;
	ActionMessage() : Message(), _action(KEYBIND_NONE) {}
	ActionMessage(KeybindingAction action) : Message(),
		_action(action) {}
};

struct KeypressMessage : public Message, public Common::KeyState {
	KeypressMessage() : Message() {}
	KeypressMessage(const Common::KeyState &ks) :
		Message(), Common::KeyState(ks) {}
};

struct MouseMessage : public Message {
	enum Button { MB_LEFT, MB_RIGHT, MB_MIDDLE };
	Button _button;
	Common::Point _pos;

	MouseMessage() : Message(), _button(MB_LEFT) {}
	MouseMessage(Button btn, const Common::Point &pos) :
		Message(), _button(btn), _pos(pos) {}
	MouseMessage(Common::EventType type, const Common::Point &pos);
};
struct MouseDownMessage : public MouseMessage {
	MouseDownMessage() : MouseMessage() {}
	MouseDownMessage(Button btn, const Common::Point &pos) :
		MouseMessage(btn, pos) {}
	MouseDownMessage(Common::EventType type, const Common::Point &pos) :
		MouseMessage(type, pos) {}
};
struct MouseUpMessage : public MouseMessage {
	MouseUpMessage() : MouseMessage() {}
	MouseUpMessage(Button btn, const Common::Point &pos) :
		MouseMessage(btn, pos) {}
	MouseUpMessage(Common::EventType type, const Common::Point &pos) :
		MouseMessage(type, pos) {}
};

struct GameMessage : public Message {
	Common::String _name;
	int _value;
	Common::String _stringValue;

	GameMessage() : Message(), _value(-1) {}
	GameMessage(const Common::String &name) : Message(),
		_name(name), _value(-1) {}
	GameMessage(const Common::String &name, int value) : Message(),
		_name(name), _value(value) {}
	GameMessage(const Common::String &name, const Common::String &strValue,
			int intValue = -1) :
		Message(), _name(name), _stringValue(strValue), _value(intValue) {}
};

struct HeaderMessage : public Message {
	Common::String _name;
	HeaderMessage() : Message() {}
	HeaderMessage(const Common::String &name) : Message(),
		_name(name) {}
};

struct Line : public Common::Point {
	Common::String _text;
	TextAlign _align = ALIGN_LEFT;

	Line() {
	}
	Line(const Common::String &text, TextAlign align = ALIGN_LEFT) :
		Common::Point(-1, -1), _text(text), _align(align) {
	}
	Line(int x1, int y1, const Common::String &text,
			TextAlign align = ALIGN_LEFT) :
		Common::Point(x1, y1), _text(text), _align(align) {
	}

	size_t size() const;
};
typedef Common::Array<Line> LineArray;

typedef void (*YNCallback)();
typedef void (*KeyCallback)(const Common::KeyState &keyState);
struct InfoMessage : public Message {
	LineArray _lines;
	YNCallback _callback = nullptr;		// Callback for timeouts and Y of Y/N queries
	YNCallback _nCallback = nullptr;	// Callback for N in Y/N queries
	KeyCallback _keyCallback = nullptr;
	bool _largeMessage = false;
	bool _sound = false;
	int _delaySeconds = 0;
	bool _fontReduced = false;

	InfoMessage();
	InfoMessage(const Common::String &str, TextAlign align = ALIGN_LEFT);
	InfoMessage(int x, int y, const Common::String &str, TextAlign align = ALIGN_LEFT);
	InfoMessage(int x1, int y1, const Common::String &str1,
		int x2, int y2, const Common::String &str2);

	InfoMessage(const Common::String &str,
		YNCallback yCallback, YNCallback nCallback = nullptr);
	InfoMessage(int x, int y, const Common::String &str,
		YNCallback yCallback, YNCallback nCallback = nullptr);
	InfoMessage(int x1, int y1, const Common::String &str1,
		int x2, int y2, const Common::String &str2,
		YNCallback ynCallback, YNCallback nCallback = nullptr);

	InfoMessage(const Common::String &str,
		KeyCallback keyCallback);
	InfoMessage(int x, int y, const Common::String &str,
		KeyCallback keyCallback);
	InfoMessage(int x1, int y1, const Common::String &str1,
		int x2, int y2, const Common::String &str2,
		KeyCallback keyCallback);
};

struct SoundMessage : public InfoMessage {
public:
	SoundMessage() : InfoMessage() { _sound = true; }
	SoundMessage(const Common::String &str, TextAlign align = ALIGN_LEFT);
	SoundMessage(int x, int y, const Common::String &str,
		TextAlign align = ALIGN_LEFT) :
		InfoMessage(x, y, str, align) { _sound = true; }
	SoundMessage(int x1, int y1, const Common::String &str1,
		int x2, int y2, const Common::String &str2) :
		InfoMessage(x1, y1, str1, x2, y2, str2) { _sound = true; }

	SoundMessage(const Common::String &str, YNCallback yCallback,
		YNCallback nCallback = nullptr);
	SoundMessage(int x, int y, const Common::String &str,
		YNCallback yCallback, YNCallback nCallback = nullptr) :
		InfoMessage(x, y, str, yCallback, nCallback) { _sound = true; }
	SoundMessage(int x1, int y1, const Common::String &str1,
		int x2, int y2, const Common::String &str2,
		YNCallback yCallback, YNCallback nCallback = nullptr) :
		InfoMessage(x1, y1, str1, x2, y2, str2, yCallback, nCallback) { _sound = true; }

	SoundMessage(const Common::String &str, KeyCallback keyCallback);
	SoundMessage(int x, int y, const Common::String &str,
		KeyCallback keyCallback) :
		InfoMessage(x, y, str, keyCallback) { _sound = true; }
	SoundMessage(int x1, int y1, const Common::String &str1,
		int x2, int y2, const Common::String &str2,
		KeyCallback keyCallback) :
		InfoMessage(x1, y1, str1, x2, y2, str2, keyCallback) { _sound = true; }
};

enum LocationType {
	LOC_TRAINING = 0, LOC_MARKET = 1, LOC_TEMPLE = 2,
	LOC_BLACKSMITH = 3, LOC_TAVERN = 4
};

struct DrawGraphicMessage : public Message {
	int _gfxNum;

	DrawGraphicMessage() : Message(), _gfxNum(0) {}
	explicit DrawGraphicMessage(int gfxNum) : Message(),
		_gfxNum(gfxNum) {}
};

} // namespace MM1
} // namespace MM

#endif