ScummVM API documentation
surface.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 LURE_SURFACE_H
23#define LURE_SURFACE_H
24
25
26#include "common/str.h"
27#include "common/ptr.h"
28#include "lure/disk.h"
29#include "lure/luredefs.h"
30
31namespace Lure {
32
33#define DEFAULT_TEXT_COLOR -1
34
35class Surface {
36private:
37 MemoryBlock *_data;
38 uint16 _width, _height;
39
40 void egaCreateDialog();
41 void vgaCreateDialog();
42 void egaRefreshDialog();
43 void vgaRefreshDialog();
44public:
45 Surface(MemoryBlock *src, uint16 width, uint16 height);
46 Surface(uint16 width, uint16 height);
47 ~Surface();
48 static uint16 textX();
49 static uint16 textY();
50 static void getDialogBounds(Common::Point &size, int charWidth, int numLines,
51 bool squashedLines = true);
52
53 static void initialize();
54 static void deinitialize();
55
56 uint16 width() { return _width; }
57 uint16 height() { return _height; }
58 MemoryBlock &data() { return *_data; }
59
60 void loadScreen(uint16 resourceId);
61 void loadScreen(MemoryBlock *data);
62 int writeChar(uint16 x, uint16 y, uint8 ascii, bool transparent, int color);
63 void writeString(uint16 x, uint16 y, Common::String line, bool transparent,
64 int color = DEFAULT_TEXT_COLOR, bool varLength = true);
65 void writeSubstring(uint16 x, uint16 y, Common::String line, int len,
66 bool transparent, int color = DEFAULT_TEXT_COLOR, bool varLength = true);
67 void transparentCopyTo(Surface *dest);
68 void copyTo(Surface *dest);
69 void copyTo(Surface *dest, uint16 x, uint16 y);
70 void copyTo(Surface *dest, const Common::Rect &srcBounds, uint16 destX, uint16 destY,
71 int transparentColor = -1);
72 void copyFrom(MemoryBlock *src) { _data->copyFrom(src); }
73 void copyFrom(MemoryBlock *src, uint32 destOffset);
74 void empty() { _data->empty(); }
75 void fillRect(const Common::Rect &r, uint8 color);
76 void createDialog();
77 void refreshDialog();
78 void copyToScreen(uint16 x, uint16 y);
79 void centerOnScreen();
80
81 static uint16 textWidth(const char *s, int numChars = 0);
82 static void wordWrap(char *text, uint16 width, char **&lines, uint8 &numLines);
83 static Surface *newDialog(uint16 width, uint8 numLines, const char **lines, bool varLength = true,
84 int color = DEFAULT_TEXT_COLOR, bool squashedLines = true);
85 static Surface *newDialog(uint16 width, const char *lines, int color = DEFAULT_TEXT_COLOR);
86 static Surface *getScreen(uint16 resourceId);
87 bool getString(Common::String &line, int maxSize, bool isNumeric, bool varLength, int16 x, int16 y);
88};
89
90class Dialog {
91public:
92 static void show(const char *text);
93 static void show(uint16 stringId, const char *hotspotName, const char *characterName);
94 static void show(uint16 stringId);
95};
96
98private:
99 Surface *_surface;
100 char _desc[MAX_DESC_SIZE];
101 char **_lines;
102 uint8 _numLines;
103 int _endLine, _endIndex;
104 int _wordCountdown;
105
106 uint16 _characterId;
107 uint16 _destCharacterId;
108 uint16 _activeItemId;
109 uint16 _descId;
110
111 int getArticle(uint16 msgId, uint16 objId);
112 void vgaTalkDialog(Surface *s);
113public:
114 TalkDialog(uint16 characterId, uint16 destCharacterId, uint16 activeItemId, uint16 descId);
115 ~TalkDialog();
116
117 char *desc() { return _desc; }
118 Surface &surface() { return *_surface; }
119 void copyTo(Surface *dest, uint16 x, uint16 y);
120 bool isBuilding() { return _endLine < _numLines; }
121
122 void saveToStream(Common::WriteStream *stream);
123 static TalkDialog *loadFromStream(Common::ReadStream *stream);
124};
125
127private:
128 static void toggleHightlight(int xs, int xe, int ys, int ye);
129public:
130 static bool show(bool saveDialog);
131};
132
134public:
135 static bool show();
136};
137
139private:
141 HotspotsList _hotspots;
142 int _charIndex;
143
144 void chooseCharacters();
145public:
147 bool show();
148};
149
151private:
152 Surface *_iconSurface;
153 bool _visible;
154
155public:
158
159 void toggleVisibility();
160 void show();
161 void hide();
162};
163
164} // End of namespace Lure
165
166#endif
Definition: list.h:44
Definition: stream.h:385
Definition: str.h:59
Definition: stream.h:77
Definition: surface.h:150
Definition: surface.h:138
Definition: surface.h:90
Definition: memory.h:31
Definition: surface.h:133
Definition: surface.h:126
Definition: surface.h:35
Definition: surface.h:97
Definition: animseq.h:27
Definition: rect.h:144
Definition: rect.h:536