ScummVM API documentation
dialog.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 DGDS_DIALOG_H
23#define DGDS_DIALOG_H
24
25#include "common/stream.h"
26#include "common/array.h"
27#include "common/error.h"
28#include "common/serializer.h"
29
30#include "dgds/dgds_rect.h"
31
32namespace Graphics {
33class ManagedSurface;
34}
35
36namespace Dgds {
37
38class DgdsFont;
39class SceneOp;
40
41enum DialogFlags {
42 kDlgFlagNone = 0,
43 kDlgFlagFlatBg = 1,
44 kDlgFlagLeftJust = 2,
45 kDlgFlagLo4 = 4,
46 kDlgFlagLo8 = 8,
47 kDlgFlagLo80 = 0x80,
48 kDlgFlagHiFinished = 0x10000,
49 kDlgFlagHi2 = 0x20000,
50 kDlgFlagHi4 = 0x40000,
51 kDlgFlagRedrawSelectedActionChanged = 0x80000,
52 kDlgFlagHi10 = 0x100000,
53 kDlgFlagHi20 = 0x200000,
54 kDlgFlagHi40 = 0x400000,
55 kDlgFlagVisible = 0x800000,
56 kDlgFlagOpening = 0x1000000,
57};
58
59enum DialogFrameType {
60 kDlgFramePlain = 1,
61 kDlgFrameBorder = 2,
62 kDlgFrameThought = 3,
63 kDlgFrameRounded = 4
64};
65
66enum DialogDrawStage {
67 kDlgDrawStageForeground = 0,
68 kDlgDrawStageBackground = 1,
69 kDlgDrawFindSelectionPointXY = 2,
70 kDlgDrawFindSelectionTxtOffset = 3,
71};
72
74 int16 num;
75 // The game initializes str offsets to pointers, but let's be a bit nicer.
76 uint16 strStart;
77 uint16 strEnd;
78 //byte unk[8]; /* Not initialized in loader */
80
81 Common::String dump(const Common::String &indent) const;
82};
83
85public:
86 DialogState() : _hideTime(0), _lastMouseX(0), _lastMouseY(0), _charWidth(0),
87 _charHeight(0), _strMouseLoc(0), _selectedAction(nullptr) {}
88 uint _hideTime;
89 DgdsRect _loc;
90 int _lastMouseX;
91 int _lastMouseY;
92 uint16 _charWidth;
93 uint16 _charHeight;
94 int _strMouseLoc;
95 struct DialogAction *_selectedAction;
96
97 Common::String dump(const Common::String &indent) const;
99};
100
101class Dialog {
102public:
103 Dialog();
104 uint16 _num;
105 uint16 _fileNum; // HOC onward
106 DgdsRect _rect;
107 uint16 _bgColor;
108 uint16 _fontColor;
109 uint16 _selectionBgCol;
110 uint16 _selectonFontCol;
111 uint16 _fontSize;
112 DialogFlags _flags;
113 DialogFrameType _frameType;
114 uint16 _time;
115 uint16 _nextDialogFileNum; // HOC onward, always set 0 in dragon.
116 uint16 _nextDialogDlgNum;
117 uint16 _talkDataNum; // Willy onward, always set 0 in dragon and HoC
118 uint16 _talkDataHeadNum; // Willy onward, always set 0 in dragon and HoC
120 Common::String _str;
121
123
124 void draw(Graphics::ManagedSurface *dst, DialogDrawStage stage);
125 void setFlag(DialogFlags flg);
126 void clearFlag(DialogFlags flg);
127 void flipFlag(DialogFlags flg);
128 bool hasFlag(DialogFlags flg) const;
129 void updateSelectedAction(int delta);
130 struct DialogAction *pickAction(bool isClosing, bool isForceClose);
131 Common::String dump(const Common::String &indent) const;
132 void clear();
133
134 Common::Error syncState(Common::Serializer &s);
135
136private:
137 void drawType1(Graphics::ManagedSurface *dst, DialogDrawStage stage);
138 void drawType2(Graphics::ManagedSurface *dst, DialogDrawStage stage);
139 void drawType3(Graphics::ManagedSurface *dst, DialogDrawStage stage);
140 void drawType4(Graphics::ManagedSurface *dst, DialogDrawStage stage);
141
142 void drawType2BackgroundDragon(Graphics::ManagedSurface *dst, const Common::String &title);
143 void drawType2BackgroundChina(Graphics::ManagedSurface *dst, const Common::String &title);
144 void drawType2BackgroundBeamish(Graphics::ManagedSurface *dst, const Common::String &title);
145
146 void drawFindSelectionXY();
147 void drawFindSelectionTxtOffset();
148 void drawForeground(Graphics::ManagedSurface *dst, uint16 fontcol, const Common::String &txt);
149
150 const DgdsFont *getDlgTextFont() const;
151
152 static int _lastSelectedDialogItemNum;
153 static Dialog *_lastDialogSelectionChangedFor;
154};
155
156
157
158} // end namespace Dgds
159
160#endif // DGDS_DIALOG_H
Definition: array.h:52
Definition: error.h:81
Definition: serializer.h:80
Definition: ptr.h:159
Definition: str.h:59
Definition: font.h:46
Definition: dgds_rect.h:32
Definition: dialog.h:101
Definition: dialog.h:84
Definition: managed_surface.h:51
Definition: formatinfo.h:28
Definition: dialog.h:73
Common::Array< SceneOp > sceneOpList
End of clickable text for this action.
Definition: dialog.h:79
Common::String dump(const Common::String &indent) const
ops to run when this is selected
uint16 strEnd
The start of the clickable text for this action.
Definition: dialog.h:77