ScummVM API documentation
dialogs.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 XEEN_DIALOGS_H
23 #define XEEN_DIALOGS_H
24 
25 #include "common/array.h"
26 #include "common/stack.h"
27 #include "common/rect.h"
28 #include "mm/xeen/cutscenes.h"
29 #include "mm/xeen/sprites.h"
30 #include "mm/shared/xeen/xsurface.h"
31 
32 namespace MM {
33 namespace Xeen {
34 
35 class XeenEngine;
36 
37 class UIButton {
38 public:
39  Common::Rect _bounds;
40  SpriteResource *_sprites;
41  int _value;
42  uint _frameNum, _selectedFrame;
43  bool _draw;
44 #ifdef USE_TTS
45  uint8 _ttsIndex;
46  bool _canVoice;
47 #endif
48 
52  UIButton(const Common::Rect &bounds, int value, uint frameNum, SpriteResource *sprites, bool draw, uint8 ttsIndex, bool ttsCanVoice) :
53  _bounds(bounds), _value(value), _frameNum(frameNum), _selectedFrame(frameNum | 1),
54  _sprites(sprites), _draw(draw) {
55 #ifdef USE_TTS
56  _ttsIndex = ttsIndex;
57  _canVoice = ttsCanVoice;
58 #endif
59  }
60 
64  UIButton() : _value(0), _frameNum(0), _selectedFrame(0), _sprites(nullptr), _draw(false) {
65 #ifdef USE_TTS
66  _ttsIndex = 0;
67  _canVoice = false;
68 #endif
69  }
70 
74  void setFrame(uint frameNum) {
75  _frameNum = frameNum;
76  _selectedFrame = frameNum | 1;
77  }
78 
82  void setFrame(uint frameNum, uint selectedFrame) {
83  _frameNum = frameNum;
84  _selectedFrame = selectedFrame;
85  }
86 };
87 
88 class ButtonContainer : public Cutscenes {
89 private:
91 protected:
92  Common::Array<UIButton> _buttons;
93  Common::StringArray _textStrings;
94  Common::Rect _waitBounds;
95  int _buttonValue;
96 #ifdef USE_TTS
97  Common::StringArray _buttonTexts;
98  int _previousButton;
99 #endif
100 
101  bool checkEvents(XeenEngine *vm);
102 
109  bool doScroll(bool rollUp, bool fadeIn) override;
110 
115  void loadStrings(const Common::Path &name);
116 
122  void loadStrings(const Common::Path &name, int ccMode);
123 
128  void setWaitBounds();
129 
130 #ifdef USE_TTS
131 
139  Common::String getNextTextSection(const Common::String &text, uint &index, uint count, const char *separator) const;
140 
148  Common::String getNextTextSection(const Common::String &text, uint &index, uint count) const;
149 
156  Common::String getNextTextSection(const Common::String &text, uint &index) const;
157 
164  Common::String addNextTextToButtons(const Common::String &text, uint &index);
165 
173  Common::String addNextTextToButtons(const Common::String &text, uint &index, uint count);
174 
179  void setButtonTexts(const Common::String &text);
180 
186  void disableButtonVoicing(uint startIndex, uint endIndex);
187 
193  void enableButtonVoicing(uint startIndex, uint endIndex);
194 #endif
195 public:
196  ButtonContainer(XeenEngine *vm) : Cutscenes(vm), _buttonValue(0) {
197 #ifdef USE_TTS
198  _previousButton = -1;
199 #endif
200  }
201 
205  void saveButtons();
206 
207  void clearButtons();
208 
209  void restoreButtons();
210 
211  void addButton(const Common::Rect &bounds, int val,
212  SpriteResource *sprites = nullptr, uint8 ttsIndex = UINT8_MAX);
213  void addButton(const Common::Rect &bounds, int val,
214  int frameNum, SpriteResource *sprites = nullptr, uint8 ttsIndex = UINT8_MAX);
215 
216  void addPartyButtons(XeenEngine *vm);
217 
221  void drawButtons(XSurface *surface);
222 
226  void clearEvents() { _buttonValue = 0; }
227 
228 #ifdef USE_TTS
229 
232  void checkHoverOverButton();
233 #endif
234 };
235 
237 protected:
238  virtual void showContents(SpriteResource &title1, bool mode);
239 public:
241 
242  ~SettingsBaseDialog() override {}
243 };
244 
245 } // End of namespace Xeen
246 } // End of namespace MM
247 
248 #endif
void clearEvents()
Definition: dialogs.h:226
Definition: str.h:59
UIButton(const Common::Rect &bounds, int value, uint frameNum, SpriteResource *sprites, bool draw, uint8 ttsIndex, bool ttsCanVoice)
Definition: dialogs.h:52
Definition: xsurface.h:45
Definition: array.h:52
Definition: dialogs.h:236
Definition: sprites.h:52
Definition: cutscenes.h:34
Definition: rect.h:524
Definition: path.h:52
UIButton()
Definition: dialogs.h:64
Definition: xeen.h:107
void setFrame(uint frameNum, uint selectedFrame)
Definition: dialogs.h:82
Definition: dialogs.h:37
void setFrame(uint frameNum)
Definition: dialogs.h:74
Definition: detection.h:27
Definition: dialogs.h:88
Definition: stack.h:102