~ubuntu-branches/debian/jessie/scummvm/jessie

« back to all changes in this revision

Viewing changes to engines/mads/dialogs.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2014-08-10 00:50:36 UTC
  • mfrom: (1.2.22)
  • Revision ID: package-import@ubuntu.com-20140810005036-wls6i0dsxqfxu70g
Tags: 1.7.0+dfsg-1
* New upstream release [July 2014].
  - remove old/obsolete patches.
  + added new "drop1test.patch" to disable problematic test.
  + build with "--disable-eventrecorder" to avoid FTBFS in tests.
  + added "libjpeg-dev" and "libfaad-dev" to Build-Depends.
* Install all arch-independent files (themes, game data, etc.).
* Build-time re-compression of "classic" theme.
* Added "debian/gbp.conf".
* Standards-Version to 3.9.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
8
 * modify it under the terms of the GNU General Public License
 
9
 * as published by the Free Software Foundation; either version 2
 
10
 * of the License, or (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, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
20
 *
 
21
 */
 
22
 
 
23
#ifndef MADS_DIALOGS_H
 
24
#define MADS_DIALOGS_H
 
25
 
 
26
#include "common/scummsys.h"
 
27
#include "mads/game.h"
 
28
#include "mads/font.h"
 
29
#include "mads/msurface.h"
 
30
 
 
31
namespace MADS {
 
32
 
 
33
class Dialog {
 
34
private:
 
35
        void setDialogPalette();
 
36
protected:
 
37
        MADSEngine *_vm;
 
38
        MSurface *_savedSurface;
 
39
        Common::Point _position;
 
40
        int _width;
 
41
        int _height;
 
42
        byte _dialogPalette[8 * 3];
 
43
 
 
44
        int TEXTDIALOG_CONTENT1;
 
45
        int TEXTDIALOG_CONTENT2;
 
46
        int TEXTDIALOG_EDGE;
 
47
        int TEXTDIALOG_BACKGROUND;
 
48
        int TEXTDIALOG_FC;
 
49
        int TEXTDIALOG_FD;
 
50
        int TEXTDIALOG_FE;
 
51
        int TEXTDIALOG_BLACK;
 
52
protected:
 
53
        /**
 
54
         * Draw the dialog
 
55
         */
 
56
        virtual void draw();
 
57
 
 
58
        /**
 
59
         * Calculate bounds for the dialog
 
60
         */
 
61
        virtual void calculateBounds();
 
62
 
 
63
        /**
 
64
        * Save the section of the passed surface the dialog will cover.
 
65
        */
 
66
        virtual void save();
 
67
 
 
68
        /**
 
69
        * Restore saved dialog surface
 
70
        */
 
71
        virtual void restore();
 
72
 
 
73
        /**
 
74
        * Draws the content of a dialog with a gravelly alternating color.
 
75
        */
 
76
        void drawContent(const Common::Rect &r, int seed, byte color1, byte color2);
 
77
public:
 
78
        /**
 
79
         * Constructor
 
80
         */
 
81
        Dialog(MADSEngine *vm);
 
82
 
 
83
        /**
 
84
         * Destructor
 
85
         */
 
86
        virtual ~Dialog();
 
87
 
 
88
        /**
 
89
         * Return the bounds of the dialog.
 
90
         */
 
91
        Common::Rect getBounds() const {
 
92
                return Common::Rect(_position.x, _position.y,
 
93
                        _position.x + _width, _position.y + _height);
 
94
        }
 
95
};
 
96
 
 
97
#define TEXT_DIALOG_MAX_LINES 20
 
98
 
 
99
class TextDialog : protected Dialog {
 
100
private:
 
101
        /**
 
102
         * Append text to the currently end line.
 
103
         */
 
104
        void appendLine(const Common::String &line);
 
105
 
 
106
        /**
 
107
         * Clean up after finishing displaying the dialog
 
108
         */
 
109
        void restorePalette();
 
110
protected:
 
111
        Font *_font;
 
112
        int _innerWidth;
 
113
        int _lineWidth;
 
114
        int _currentX;
 
115
        int _numLines;
 
116
        int _lineSize;
 
117
        int _askXp;
 
118
        int _askLineNum;
 
119
        Common::String _lines[TEXT_DIALOG_MAX_LINES];
 
120
        int _lineXp[TEXT_DIALOG_MAX_LINES];
 
121
 
 
122
        /**
 
123
         * Calculate the bounds for the dialog
 
124
         */
 
125
        virtual void calculateBounds();
 
126
public:
 
127
        /**
 
128
         * Constructor
 
129
         * @param vm                    Engine reference
 
130
         * @param fontName              Font to use for display
 
131
         * @param pos                   Position for window top-left
 
132
         * @param maxChars              Horizontal width of window in characters
 
133
         */
 
134
        TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos,
 
135
                int maxChars);
 
136
 
 
137
        /**
 
138
         * Destructor
 
139
         */
 
140
        virtual ~TextDialog();
 
141
 
 
142
        /**
 
143
         * Draw the dialog
 
144
         */
 
145
        virtual void draw();
 
146
 
 
147
        /**
 
148
         * Draw the dialog along with any input box
 
149
         */
 
150
        void drawWithInput();
 
151
 
 
152
        /**
 
153
        * Add a new line to the dialog
 
154
        */
 
155
        void addLine(const Common::String &line, bool underline = false);
 
156
 
 
157
        /**
 
158
        * Adds one or more lines, word wrapping the passed text
 
159
        */
 
160
        void wordWrap(const Common::String &line);
 
161
 
 
162
        /**
 
163
        * Increments the number of text lines the text dialog uses
 
164
        */
 
165
        void incNumLines();
 
166
 
 
167
        /**
 
168
        * Adds an input area following previously added text
 
169
        */
 
170
        void addInput();
 
171
 
 
172
        /**
 
173
         * Adds a bar line to separate sections of text
 
174
         */
 
175
        void addBarLine();
 
176
 
 
177
        /**
 
178
        * Flags the previously added line to be underlined
 
179
        */
 
180
        void underlineLine();
 
181
 
 
182
        void downPixelLine();
 
183
 
 
184
        /**
 
185
         * Set the x position for the given line
 
186
         */
 
187
        void setLineXp(int xp);
 
188
 
 
189
        /**
 
190
        * Show the dialog, and wait until a key or mouse press.
 
191
        */
 
192
        virtual void show();
 
193
};
 
194
 
 
195
class MessageDialog : public TextDialog {
 
196
public:
 
197
        MessageDialog(MADSEngine *vm, int lines, ...);
 
198
 
 
199
        virtual ~MessageDialog() {}
 
200
};
 
201
 
 
202
enum DialogId {
 
203
        DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3,
 
204
        DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6
 
205
};
 
206
 
 
207
class Dialogs {
 
208
protected:
 
209
        MADSEngine *_vm;
 
210
 
 
211
        Dialogs(MADSEngine *vm);
 
212
public:
 
213
        static Dialogs *init(MADSEngine *vm);
 
214
public:
 
215
        Common::Point _defaultPosition;
 
216
        DialogId _pendingDialog;
 
217
        int _indexList[10];
 
218
 
 
219
        virtual ~Dialogs() {}
 
220
 
 
221
        virtual void showDialog() = 0;
 
222
        virtual void showItem(int objectId, int messageId, int speech = 0) = 0;
 
223
        virtual Common::String getVocab(int vocabId) = 0;
 
224
        virtual bool show(int messageId, int objectId = -1) = 0;
 
225
};
 
226
 
 
227
} // End of namespace MADS
 
228
 
 
229
#endif /* MADS_DIALOGS_H */