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/nebular/core/msurface.h"
29 #include "mads/nebular/core/screen.h"
30 
31 namespace MADS {
32 namespace Nebular {
33 
34 enum {
35  IMG_SPINNING_OBJECT = 200, IMG_TEXT_UPDATE = 201
36 };
37 
38 enum ScrollbarActive {
39  SCROLLBAR_NONE = 0, // No state
40  SCROLLBAR_UP = 1, // Up butotn
41  SCROLLBAR_DOWN = 2, // Down button
42  SCROLLBAR_ELEVATOR = 3, // Elevator bar
43  SCROLLBAR_THUMB = 4 // Scrollbar thumb
44 };
45 
46 class AnimFrameEntry;
47 class RexNebularEngine;
48 
49 class UISlot {
50 public:
51  int _flags;
52  int _segmentId;
53  int _spritesIndex;
54  int _frameNumber;
55  Common::Point _position;
56 
57  // Only used for IMG_OVERPRINT
58  int _width;
59  int _height;
60 
61  UISlot();
62 };
63 
67 class UISlots : public Common::Array<UISlot> {
68 private:
69  RexNebularEngine *_vm;
70 public:
74  UISlots(RexNebularEngine *vm) : _vm(vm) {
75  }
76 
80  void add(const Common::Rect &bounds);
81 
85  void add(const AnimFrameEntry &frameEntry);
86 
90  void fullRefresh();
91 
97  void draw(bool updateFlag, bool delFlag);
98 };
99 
101 private:
102  static RexNebularEngine *_vm;
103 public:
104  static void init(RexNebularEngine *vm);
105 public:
106  int _globalId;
107  Common::Array<int> _quotes;
108 
112  void setup(int globalId, ...);
113 
117  void set(int quoteId, ...);
118 
123  int read(int quoteId);
124 
128  void write(int quoteId, bool flag);
129 
133  void start();
134 };
135 
136 class UserInterface : public MSurface {
137  friend class UISlots;
138 private:
139  RexNebularEngine *_vm;
140  int _invSpritesIndex;
141  int _invFrameNumber;
142  uint32 _scrollMilli;
143  bool _scrollFlag;
144  int _noSegmentsActive;
145  int _someSegmentsActive;
146 
150  void loadElements();
151 
155  bool getBounds(ScrCategory category, int invIndex, Common::Rect &bounds);
156 
160  void moveRect(Common::Rect &bounds);
161 
165  void drawConversationList();
166 
170  void drawActions();
171 
175  void drawInventoryList();
176 
180  void drawItemVocabList();
181 
185  void drawScroller();
186 
190  void scrollbarChanged();
191 
195  void writeVocab(ScrCategory category, int id);
196 public:
197  MSurface _surface;
198  UISlots _uiSlots;
199  DirtyAreas _dirtyAreas;
200  ScrCategory _category;
201  Common::Rect *_rectP;
202  int _inventoryTopIndex;
203  int _selectedInvIndex;
204  int _selectedActionIndex;
205  int _selectedItemVocabIdx;
206  ScrollbarActive _scrollbarActive, _scrollbarOldActive;
207  int _highlightedCommandIndex;
208  int _highlightedInvIndex;
209  int _highlightedItemVocabIndex;
210  bool _inventoryChanged;
211  int _categoryIndexes[8];
212  Common::StringArray _talkStrings;
213  Common::Array<int> _talkIds;
214  bool _scrollbarQuickly;
215  uint32 _scrollbarMilliTime;
216  int _scrollbarElevator, _scrollbarOldElevator;
217  ScrollbarActive _scrollbarStrokeType;
218 public:
223 
227  void load(const Common::Path &resName) override;
228 
232  void setup(InputMode inputMode);
233 
234  void drawTextElements();
235 
244  void mergeFrom(BaseSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos,
245  int transparencyIndex = -1);
246 
250  void loadInventoryAnim(int objectId);
251 
255  void noInventoryAnim();
256 
260  void doBackgroundAnimation();
261 
265  void inventoryAnim();
266 
267  void categoryChanged();
268 
273  void selectObject(int invIndex);
274 
275  void updateSelection(ScrCategory category, int newIndex, int *idx);
276 
280  void changeScrollBar();
281 
282  void scrollerChanged();
283 
284  void scrollInventory();
285 
290  void updateInventoryScroller();
291 
295  void emptyConversationList();
296 
300  void addConversationMessage(int vocabId, const Common::String &msg);
301 
305  void synchronize(Common::Serializer &s);
306 
307  void refresh();
308 };
309 
310 } // namespace Nebular
311 } // namespace MADS
312 
313 #endif
Definition: str.h:59
Definition: nebular.h:51
Definition: array.h:52
UISlots(RexNebularEngine *vm)
Definition: user_interface.h:74
Definition: rect.h:524
Definition: path.h:52
Definition: screen.h:99
Definition: serializer.h:80
Definition: msurface.h:56
Definition: user_interface.h:67
Definition: user_interface.h:136
Definition: rect.h:144
Definition: user_interface.h:100
Definition: sound_manager.h:38
Definition: msurface.h:188
Definition: animation.h:67
Definition: user_interface.h:49