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/rect.h"
29 #include "common/serializer.h"
30 
31 #include "dgds/dgds_rect.h"
32 
33 namespace Graphics {
34 class ManagedSurface;
35 }
36 
37 namespace Dgds {
38 
39 class DgdsFont;
40 class SceneOp;
41 
42 enum DialogFlags {
43  kDlgFlagNone = 0,
44  kDlgFlagFlatBg = 1,
45  kDlgFlagLeftJust = 2,
46  kDlgFlagLo4 = 4,
47  kDlgFlagLo8 = 8,
48  kDlgFlagLo80 = 0x80,
49  kDlgFlagHiFinished = 0x10000,
50  kDlgFlagHi2 = 0x20000,
51  kDlgFlagHi4 = 0x40000,
52  kDlgFlagRedrawSelectedActionChanged = 0x80000,
53  kDlgFlagHi10 = 0x100000,
54  kDlgFlagHi20 = 0x200000,
55  kDlgFlagHi40 = 0x400000,
56  kDlgFlagVisible = 0x800000,
57  kDlgFlagOpening = 0x1000000,
58 };
59 
60 enum DialogFrameType {
61  kDlgFramePlain = 1,
62  kDlgFrameBorder = 2,
63  kDlgFrameThought = 3,
64  kDlgFrameRounded = 4
65 };
66 
67 enum DialogDrawStage {
68  kDlgDrawStageForeground = 0,
69  kDlgDrawStageBackground = 1,
70  kDlgDrawFindSelectionPointXY = 2,
71  kDlgDrawFindSelectionTxtOffset = 3,
72 };
73 
74 struct DialogAction {
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 
84 class DialogState {
85 public:
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;
98  Common::Error syncState(Common::Serializer &s);
99 };
100 
101 class Dialog {
102 public:
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 _unk1; // Willy onward, always set 0 in dragon and HoC
118  uint16 _unk2; // 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 
136  void fixupStringAndActions();
137 
138 private:
139  void drawType1(Graphics::ManagedSurface *dst, DialogDrawStage stage);
140  void drawType2(Graphics::ManagedSurface *dst, DialogDrawStage stage);
141  void drawType3(Graphics::ManagedSurface *dst, DialogDrawStage stage);
142  void drawType4(Graphics::ManagedSurface *dst, DialogDrawStage stage);
143 
144  void drawType2BackgroundDragon(Graphics::ManagedSurface *dst, const Common::String &title);
145  void drawType2BackgroundChina(Graphics::ManagedSurface *dst, const Common::String &title);
146  void drawType2BackgroundBeamish(Graphics::ManagedSurface *dst, const Common::String &title);
147 
148  void drawFindSelectionXY();
149  void drawFindSelectionTxtOffset();
150  void drawForeground(Graphics::ManagedSurface *dst, uint16 fontcol, const Common::String &txt);
151 
152  const DgdsFont *getDlgTextFont() const;
153 
154  static int _lastSelectedDialogItemNum;
155  static Dialog *_lastDialogSelectionChangedFor;
156 };
157 
158 
159 
160 } // end namespace Dgds
161 
162 #endif // DGDS_DIALOG_H
Definition: managed_surface.h:51
Common::Array< SceneOp > sceneOpList
End of clickable text for this action.
Definition: dialog.h:79
Definition: str.h:59
Definition: error.h:84
Definition: dialog.h:74
Definition: dialog.h:101
Definition: array.h:52
Definition: ads.h:28
Definition: dialog.h:84
Definition: font.h:46
uint16 strEnd
The start of the clickable text for this action.
Definition: dialog.h:77
Definition: serializer.h:79
Definition: dgds_rect.h:32
Definition: formatinfo.h:28
Definition: ptr.h:159