ScummVM API documentation
user_interface.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 MADS_USER_INTERFACE_H
23 #define MADS_USER_INTERFACE_H
24 
25 #include "common/scummsys.h"
26 #include "common/rect.h"
27 #include "common/str.h"
28 #include "mads/msurface.h"
29 #include "mads/screen.h"
30 
31 namespace MADS {
32 
33 enum { IMG_SPINNING_OBJECT = 200, IMG_TEXT_UPDATE = 201 };
34 
35 enum ScrollbarActive {
36  SCROLLBAR_NONE = 0, // No state
37  SCROLLBAR_UP = 1, // Up butotn
38  SCROLLBAR_DOWN = 2, // Down button
39  SCROLLBAR_ELEVATOR = 3, // Elevator bar
40  SCROLLBAR_THUMB = 4 // Scrollbar thumb
41 };
42 
43 class AnimFrameEntry;
44 class MADSEngine;
45 
46 class UISlot {
47 public:
48  int _flags;
49  int _segmentId;
50  int _spritesIndex;
51  int _frameNumber;
52  Common::Point _position;
53 
54  // Only used for IMG_OVERPRINT
55  int _width;
56  int _height;
57 
58  UISlot();
59 };
60 
64 class UISlots : public Common::Array<UISlot> {
65 private:
66  MADSEngine *_vm;
67 public:
71  UISlots(MADSEngine *vm) : _vm(vm) {}
72 
76  void add(const Common::Rect &bounds);
77 
81  void add(const AnimFrameEntry &frameEntry);
82 
86  void fullRefresh();
87 
93  void draw(bool updateFlag, bool delFlag);
94 };
95 
96 class Conversation {
97 private:
98  static MADSEngine *_vm;
99 public:
100  static void init(MADSEngine *vm);
101 public:
102  int _globalId;
103  Common::Array<int> _quotes;
104 
108  void setup(int globalId, ...);
109 
113  void set(int quoteId, ...);
114 
119  int read(int quoteId);
120 
124  void write(int quoteId, bool flag);
125 
129  void start();
130 };
131 
132 class UserInterface : public MSurface {
133  friend class UISlots;
134 private:
135  MADSEngine *_vm;
136  int _invSpritesIndex;
137  int _invFrameNumber;
138  uint32 _scrollMilli;
139  bool _scrollFlag;
140  int _noSegmentsActive;
141  int _someSegmentsActive;
142 
146  void loadElements();
147 
151  bool getBounds(ScrCategory category, int invIndex, Common::Rect &bounds);
152 
156  void moveRect(Common::Rect &bounds);
157 
161  void drawConversationList();
162 
166  void drawActions();
167 
171  void drawInventoryList();
172 
176  void drawItemVocabList();
177 
181  void drawScroller();
182 
186  void scrollbarChanged();
187 
191  void writeVocab(ScrCategory category, int id);
192 public:
193  MSurface _surface;
194  UISlots _uiSlots;
195  DirtyAreas _dirtyAreas;
196  ScrCategory _category;
197  Common::Rect *_rectP;
198  int _inventoryTopIndex;
199  int _selectedInvIndex;
200  int _selectedActionIndex;
201  int _selectedItemVocabIdx;
202  ScrollbarActive _scrollbarActive, _scrollbarOldActive;
203  int _highlightedCommandIndex;
204  int _highlightedInvIndex;
205  int _highlightedItemVocabIndex;
206  bool _inventoryChanged;
207  int _categoryIndexes[8];
208  Common::StringArray _talkStrings;
209  Common::Array<int> _talkIds;
210  bool _scrollbarQuickly;
211  uint32 _scrollbarMilliTime;
212  int _scrollbarElevator, _scrollbarOldElevator;
213  ScrollbarActive _scrollbarStrokeType;
214 public:
219 
223  void load(const Common::Path &resName) override;
224 
228  void setup(InputMode inputMode);
229 
230  void drawTextElements();
231 
240  void mergeFrom(BaseSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos,
241  int transparencyIndex = -1);
242 
246  void loadInventoryAnim(int objectId);
247 
251  void noInventoryAnim();
252 
256  void doBackgroundAnimation();
257 
261  void inventoryAnim();
262 
263  void categoryChanged();
264 
269  void selectObject(int invIndex);
270 
271  void updateSelection(ScrCategory category, int newIndex, int *idx);
272 
276  void changeScrollBar();
277 
278  void scrollerChanged();
279 
280  void scrollInventory();
281 
286  void updateInventoryScroller();
287 
291  void emptyConversationList();
292 
296  void addConversationMessage(int vocabId, const Common::String &msg);
297 
301  void synchronize(Common::Serializer &s);
302 
303  void refresh();
304 };
305 
306 } // End of namespace MADS
307 
308 #endif /* MADS_USER_INTERFACE_H */
Definition: screen.h:97
Definition: msurface.h:55
Definition: str.h:59
Definition: array.h:52
Definition: rect.h:144
Definition: path.h:52
Definition: animation.h:66
Definition: serializer.h:79
Definition: user_interface.h:64
Definition: rect.h:45
UISlots(MADSEngine *vm)
Definition: user_interface.h:71
Definition: mads.h:87
Definition: user_interface.h:132
Definition: action.h:28
Definition: msurface.h:172
Definition: user_interface.h:46
Definition: user_interface.h:96