ScummVM API documentation
dialogs.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * Inventory related functions
22  */
23 
24 #ifndef TINSEL_INVENTORY_H // prevent multiple includes
25 #define TINSEL_INVENTORY_H
26 
27 #include "tinsel/dw.h"
28 #include "tinsel/events.h" // for PLR_EVENT, PLR_EVENT
29 #include "tinsel/inv_objects.h"
30 #include "tinsel/object.h"
31 #include "tinsel/movers.h"
32 
33 namespace Common {
34 class Serializer;
35 struct KeyState;
36 }
37 
38 namespace Tinsel {
39 
40 struct OBJECT;
41 struct FREEL;
42 struct FILM;
43 struct CONFINIT;
44 
45 enum {
46  INV_OPEN = -1, // DW1 only
47  INV_CONV = 0,
48  INV_1 = 1,
49  INV_2 = 2,
50  DW0_INV_CONF = 3,
51  INV_MENU = 3, // DW2 constant
52  NUM_INV_V0 = 4,
53 
54  // Discworld 2 constants
55  DW2_INV_OPEN = 5,
56  INV_DEFAULT = 6,
57 
58  // Noir constants
59  INV_3 = 3,
60  INV_4 = 4,
61  NOIR_INV_CONF = 5,
62  NUM_INV_V3 = 6,
63  INV_7NOINV = 7,
64  INV_8NOINV = 8,
65  INV_NOTEBOOK = 9,
66 
67  MAX_NUM_INV = NUM_INV_V3 // For determination of _invD array size
68 };
69 
70 #define INV_CONF ((TinselVersion == 3) ? NOIR_INV_CONF : DW0_INV_CONF)
71 #define NUM_INV ((TinselVersion == 3) ? NUM_INV_V3 : NUM_INV_V0)
72 
73 enum {
74  NOOBJECT = -1,
75  INV_NOICON_V0 = -1,
76  INV_CLOSEICON = -2,
77  INV_OPENICON = -3,
78  INV_HELDNOTIN_V0 = -4,
79  // Noir discerns between NOOBJECT and INV_NOICON
80  INV_NOICON_V3 = 0,
81  INV_HELDNOTIN_V3 = 1,
82  INV_HELDIN = 2,
83 };
84 
85 #define INV_NOICON ((TinselVersion == 3) ? INV_NOICON_V3 : INV_NOICON_V0)
86 #define INV_HELDNOTIN ((TinselVersion == 3) ? INV_HELDNOTIN_V3 : INV_HELDNOTIN_V0)
87 
88 enum CONV_PARAM {
89  CONV_DEF,
90  CONV_BOTTOM,
91  CONV_END,
92  CONV_TOP
93 };
94 
95 enum InventoryType { EMPTY,
96  FULL,
97  CONF };
98 
99 enum InvCursorFN { IC_AREA,
100  IC_DROP };
101 
102 #define sliderRange (_sliderYmax - _sliderYmin)
103 #define MAXSLIDES 4
104 #define MAX_PERMICONS 10 // Max permanent conversation icons
105 #define MAXHICONS 10 // Max dimensions of
106 #define MAXVICONS 6 // an inventory window
107 #define SG_DESC_LEN 40 // Max. saved game description length
108 
109 // Number of objects that makes up an empty window
110 #define MAX_WCOMP_T0 21 // 4 corners + (3+3) sides + (2+2) extra sides
111  // + Bground + title + slider
112  // + more Needed for save game window
113 #define MAX_WCOMP_T3 84
114 #define MAX_WCOMP (TinselVersion == 3 ? MAX_WCOMP_T3 : MAX_WCOMP_T0)
115 
116 #define MAX_ICONS MAXHICONS *MAXVICONS
117 #define MAX_ININV_TOT 160
118 
119 enum CONFTYPE {
120  MAIN_MENU,
121  SAVE_MENU,
122  LOAD_MENU,
123  QUIT_MENU,
124  RESTART_MENU,
125  SOUND_MENU,
126  CONTROLS_MENU,
127  SUBTITLES_MENU,
128  HOPPER_MENU1,
129  HOPPER_MENU2,
130  TOP_WINDOW
131 };
132 
133 struct INV_DEF {
134  int MinHicons; // }
135  int MinVicons; // } Dimension limits
136  int MaxHicons; // }
137  int MaxVicons; // }
138 
139  int NoofHicons; // }
140  int NoofVicons; // } Current dimentsions
141 
142  int contents[160]; // Contained items
143  int NoofItems; // Current number of held items
144 
145  int FirstDisp; // Index to first item currently displayed
146 
147  int inventoryX; // } Display position
148  int inventoryY; // }
149  int otherX; // } Display position
150  int otherY; // }
151 
152  int MaxInvObj; // Max. allowed contents
153 
154  SCNHANDLE hInvTitle; // Window heading
155 
156  bool resizable; // Re-sizable window?
157  bool bMoveable; // Moveable window?
158 
159  int sNoofHicons; // }
160  int sNoofVicons; // } Current dimensions
161 
162  bool bMax; // Maximised last time open?
163 };
164 
165 //----- Data pertinant to scene hoppers ------------------------
166 
167 struct HOPPER {
168  uint32 hScene;
169  SCNHANDLE hSceneDesc;
170  uint32 numEntries;
171  uint32 entryIndex;
172 };
173 
174 struct HOPENTRY {
175  uint32 eNumber; // entrance number
176  SCNHANDLE hDesc; // handle to entrance description
177  uint32 flags;
178 };
179 
180 enum BTYPE {
185  ARSGBUT,
191  DCTEST,
192  FLIP,
193  FRGROUP,
194  ROTATE,
195  NOTHING
196 };
197 
198 enum BFUNC {
199  NOFUNC,
200  SAVEGAME,
201  LOADGAME,
202  IQUITGAME,
203  CLOSEWIN,
204  OPENLOAD,
205  OPENSAVE,
206  OPENREST,
207  OPENSOUND,
208  OPENCONT,
209 #ifndef JAPAN
210  OPENSUBT,
211 #endif
212  OPENQUIT,
213  INITGAME,
214  MUSICVOL,
215 
216  HOPPER2, // Call up Scene Hopper 2
217  BF_CHANGESCENE,
218 
219  CLANG,
220  RLANG
221 #ifdef MAC_OPTIONS
222  ,
223  MASTERVOL,
224  SAMPVOL
225 #endif
226 };
227 
228 enum TM { TM_POINTER,
229  TM_INDEX,
230  TM_STRINGNUM,
231  TM_UNK4,
232  TM_NONE };
233 
234 // For slideSlider() and similar
235 enum SSFN {
236  S_START,
237  S_SLIDE,
238  S_END,
239  S_TIMEUP,
240  S_TIMEDN
241 };
242 
243 struct CONFBOX {
244  BTYPE boxType;
245  BFUNC boxFunc;
246  TM textMethod;
247 
248  char *boxText;
249  int ixText;
250  int xpos;
251  int ypos;
252  int w; // Doubles as max value for SLIDERs
253  int h; // Doubles as iteration size for SLIDERs
254  int *ival;
255  int bi; // Base index for AAGBUTs
256 };
257 
258 // Data for button press/toggle effects
259 struct BUTTONEFFECT {
260  bool bButAnim;
261  CONFBOX *box;
262  bool press; // true = button press; false = button toggle
263 };
264 
265 enum class SysReel;
266 
267 class Dialogs {
268 public:
269  Dialogs();
270  virtual ~Dialogs();
271 
272  void popUpInventory(int invno, int menuId = -1);
273  void openMenu(CONFTYPE menuType);
274 
275  void xMovement(int x);
276  void yMovement(int y);
277 
278  void eventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds);
279 
280  int whichItemHeld();
281 
282  void holdItem(int item, bool bKeepFilm = false);
283  void dropItem(int item);
284  void clearInventory(int invno);
285  void addToInventory(int invno, int icon, bool hold = false);
286  bool remFromInventory(int invno, int icon);
287 
288  void registerIcons(void *cptr, int num);
289 
290  void idec_convw(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
291  int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
292  void idec_inv1(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
293  int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
294  void idec_inv2(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
295  int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
296 
297  // Noir
298  Common::Array<int> getAllNotebookClues() const;
299  void idec_invMain(SCNHANDLE text, int MaxContents);
300 
301  bool inventoryActive();
302  bool inventoryOrNotebookActive();
303 
304  void permaConvIcon(int icon, bool bEnd = false);
305 
306  void convPos(int bpos);
307  void convPoly(HPOLYGON hPoly);
308  int getIcon();
309  void closeDownConv();
310  void hideConversation(bool hide);
311  bool convIsHidden();
312 
313  void convAction(int index);
314  void setConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano);
315  void inventoryIconCursor(bool bNewItem);
316 
317  void setInvWinParts(SCNHANDLE hf);
318  void setFlagFilms(SCNHANDLE hf);
319  void setConfigStrings(SCNHANDLE *tp);
320 
321  int invItem(Common::Point &coOrds, bool update);
322  int invItem(int *x, int *y, bool update);
323  int invItemId(int x, int y);
324 
325  int inventoryPos(int num);
326 
327  bool isInInventory(int object, int invnum);
328 
329  void killInventory();
330 
331  void syncInvInfo(Common::Serializer &s);
332 
333  int invGetLimit(int invno);
334  void invSetLimit(int invno, int MaxContents);
335  void invSetSize(int invno, int MinWidth, int MinHeight,
336  int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
337 
338  bool getIsInvObject(int id);
339 
340  int whichInventoryOpen();
341 
342  bool isTopWindow();
343  bool menuActive();
344  bool isConvWindow();
345 
346  const FILM *getObjectFilm(int object) const;
347  void setObjectFilm(int object, SCNHANDLE hFilm);
348  void callFunction(BFUNC boxFunc);
349 
350  OBJECT *addObject(const FREEL *pfreel, int num);
351  void invPutDown(int index);
352  void slideMSlider(int x, SSFN fn);
353  void addBoxes(bool posnSlide);
354  void select(int i, bool force);
355  void fillInInventory();
356  void invCursor(InvCursorFN fn, int CurX, int CurY);
357  const InventoryObject *getInvObject(int id);
358  const InventoryObjectT3 *getInvObjectT3(int id);
359  void invPointEvent(const InventoryObject *invObj, int index);
360  bool updateString(const Common::KeyState &kbd);
361  bool inventoryIsActive() { return _inventoryState == ACTIVE_INV; }
362  bool isMixingDeskControl() { return _invDragging == ID_MDCONT; }
363  int currentInventoryX() { return _invD[_activeInv].inventoryX; }
364  int currentInventoryY() { return _invD[_activeInv].inventoryY; }
365  bool configurationIsActive() { return _activeInv == INV_CONF; }
366  bool displayObjectsActive() { return _objArray[0] != NULL; }
367  bool inventoryIsHidden() { return _InventoryHidden; }
368  const FILM *getWindowData();
369  void redraw();
370 
371  // Noir
372  bool isConvAndNotMove();
373 
374  bool _noLanguage;
375  int _glitterIndex;
376  volatile int _pointedWaitCount; // used by ObjectProcess - fix the 'repeated pressing bug'
377  // For editing save game names
378  char _saveGameDesc[SG_DESC_LEN + 2];
379 
380  OBJECT *_iconArray[MAX_ICONS]; // Current display objects (icons)
381  BUTTONEFFECT _buttonEffect;
382 
383 private:
384  int whichMenuBox(int curX, int curY, bool bSlides);
385  void confActionSpecial(int i);
386  bool rePosition();
387  bool languageChange();
388  void primeSceneHopper();
389  void freeSceneHopper();
390  void rememberChosenScene();
391  void setChosenScene();
392  void firstEntry(int first);
393  void hopAction();
394  void dumpIconArray();
395  void dumpDobjArray();
396  void dumpObjArray();
397  void firstScene(int first);
398  void firstFile(int first);
399  int getObjectIndex(int id) const;
400  void invSaveGame();
401  void invLoadGame();
402  int invArea(int x, int y);
403  void invBoxes(bool InBody, int curX, int curY);
404  void invLabels(bool InBody, int aniX, int aniY);
405  void adjustTop();
406  OBJECT *addInvObject(int num, SCNHANDLE *hNewScript, int *aniSpeed);
407  void addBackground(OBJECT **rect, const Common::Rect &bounds, OBJECT **title = nullptr, int textFrom = 0);
408  void addTitle(OBJECT **title, const Common::Rect &rect);
409  void addSlider(OBJECT **slide, const FILM *pfilm);
410  void addBox(int *pi, const int i);
411  void addEWSlider(OBJECT **slide, const FILM *pfilm);
412  void positionInventory(OBJECT *pMultiObj, int xOffset, int yOffset, int zPosition);
413  int addExtraWindow(int x, int y, OBJECT **retObj);
414  void constructInventoryCommon(SysReel reel, bool hasTitle);
415  void constructConversationInventory();
416  void constructInventory(InventoryType filling);
417  void constructOtherInventory(int menuId);
418  void constructMainInventory();
419  void alterCursor(int num);
420  void setMenuGlobals(CONFINIT *ci);
421  void closeInventory();
422  int nearestSlideY(int fity);
423  void slideSlider(int y, SSFN fn);
424  void slideCSlider(int y, SSFN fn);
425  void gettingTaller();
426  void gettingShorter();
427  void gettingWider();
428  void gettingNarrower();
429  void changeingSize();
430  void invDragStart();
431  void invDragEnd();
432  bool menuDown(int lines);
433  bool menuUp(int lines);
434  void menuRollDown();
435  void menuRollUp();
436  void menuPageDown();
437  void menuPageUp();
438  void inventoryDown();
439  void inventoryUp();
440  void menuAction(int i, bool dbl);
441  void invPickup(int index);
442  void invWalkTo(const Common::Point &coOrds);
443  void invAction();
444  void invLook(const Common::Point &coOrds);
445  void idec_inv(int num, SCNHANDLE text, int MaxContents,
446  int MinWidth, int MinHeight,
447  int StartWidth, int StartHeight,
448  int MaxWidth, int MaxHeight,
449  int startx, int starty, bool moveable);
450 
451  //----- Permanent data (set once) -----
452  SCNHANDLE _flagFilm; // Window members and cursors' graphic data
453  SCNHANDLE _configStrings[20];
454 
455  INV_DEF _invD[MAX_NUM_INV]; // Conversation + 2 inventories + ...
456  int _activeInv; // Which inventory is currently active
457  InventoryObjects *_invObjects; // Inventory objects' data
458  SCNHANDLE *_invFilms;
459  DIRECTION _initialDirection;
460 
461  //----- Permanent data (updated, valid while inventory closed) -----
462  int _heldItem; // Current held item
463 
464  SCNHANDLE _heldFilm;
465  SCNHANDLE _hWinParts; // Window members and cursors' graphic data
466 
467  // Permanent contents of conversation inventory
468  int _permIcons[MAX_PERMICONS]; // Basic items i.e. permanent contents
469  int _numPermIcons; // - copy to conv. inventory at pop-up time
470  int _numEndIcons;
471 
472  //----- Data pertinant to current active inventory -----
473 
474  bool _InventoryHidden;
475  bool _InventoryMaximised;
476  bool _ItemsChanged; // When set, causes items to be re-drawn
477 
478  int _SuppH; // 'Linear' element of
479  int _SuppV; // dimensions during re-sizing
480 
481  int _yChange; //
482  int _yCompensate; // All to do with re-sizing.
483  int _xChange; //
484  int _xCompensate; //
485 
486  bool _reOpenMenu;
487 
488  int _TL, _TR, _BL, _BR; // Used during window construction
489  int _TLwidth, _TLheight; //
490  int _TRwidth; //
491  int _BLheight; //
492 
493  LANGUAGE _displayedLanguage;
494 
495  OBJECT *_objArray[MAX_WCOMP_T3]; // Current display objects (window)
496  OBJECT *_dispObjArray[MAX_WCOMP_T3]; // Current display objects (re-sizing window)
497  ANIM _iconAnims[MAX_ICONS];
498 
499  OBJECT *_rectObject, *_slideObject; // Current display objects, for reference
500  // objects are in objArray.
501 
502  int _sliderYpos; // For positioning the slider
503  int _sliderYmax, _sliderYmin; //
504 
505  // Also to do with the slider
506  struct {
507  int n;
508  int y;
509  } _slideStuff[MAX_ININV_TOT + 1];
510 
511  struct MDSLIDES {
512  int num;
513  OBJECT *obj;
514  int min, max;
515  };
516  MDSLIDES _mdSlides[MAXSLIDES];
517  int _numMdSlides;
518 
519  // Icon clicked on to cause an event
520  // - Passed to conversation polygon or actor code via Topic()
521  // - (sometimes) Passed to inventory icon code via OtherObject()
522  int _thisIcon;
523 
524  CONV_PARAM _thisConvFn; // Top, 'Middle' or Bottom
525  HPOLYGON _thisConvPoly; // Conversation code is in a polygon code block
526  int _thisConvActor; // ...or an actor's code block.
527  int _pointedIcon; // used by invLabels - icon pointed to on last call
528  int _sX; // used by slideMSlider() - current x-coordinate
529  int _lX; // used by slideMSlider() - last x-coordinate
530 
531  bool _bMoveOnUnHide; // Set before start of conversation
532  // - causes conversation to be started in a sensible place
533 
534  HOPPER *_pHopper;
535  HOPENTRY *_pEntries;
536  int _numScenes;
537 
538  int _numEntries;
539 
540  HOPPER *_pChosenScene;
541 
542  int _lastChosenScene;
543  bool _bRemember;
544  enum { IC_NORMAL,
545  IC_DR,
546  IC_UR,
547  IC_TB,
548  IC_LR,
549  IC_INV,
550  IC_UP,
551  IC_DN } _invCursor;
552 
553  enum { NO_INV,
554  IDLE_INV,
555  ACTIVE_INV,
556  BOGUS_INV } _inventoryState;
557 
558  enum { ID_NONE,
559  ID_MOVE,
560  ID_SLIDE,
561  ID_BOTTOM,
562  ID_TOP,
563  ID_LEFT,
564  ID_RIGHT,
565  ID_TLEFT,
566  ID_TRIGHT,
567  ID_BLEFT,
568  ID_BRIGHT,
569  ID_CSLIDE,
570  ID_MDCONT } _invDragging;
571 };
572 
573 void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, int myEscape, bool *result = NULL);
574 
575 } // End of namespace Tinsel
576 
577 #endif /* TINSEL_INVENTRY_H */
Definition: inv_objects.h:80
uint32 SCNHANDLE
Definition: dw.h:31
Definition: inv_objects.h:105
Definition: dialogs.h:133
Definition: anim.h:33
BTYPE
Definition: dialogs.h:180
Definition: rect.h:144
Action always, text box.
Definition: dialogs.h:184
Discworld 2 toggle type 2.
Definition: dialogs.h:190
Discworld 2 toggle type 1.
Definition: dialogs.h:189
Action always, graphic button.
Definition: dialogs.h:186
Definition: serializer.h:79
TINSEL_EVENT
Definition: events.h:91
Definition: object.h:73
#define CORO_PARAM
Definition: coroutines.h:107
Not a button at all.
Definition: dialogs.h:187
Definition: algorithm.h:29
Definition: actors.h:36
Definition: rect.h:45
Definition: dialogs.h:259
Definition: film.h:32
Definition: dialogs.h:267
Discworld 1 toggle.
Definition: dialogs.h:188
Definition: film.h:40
Definition: inv_objects.h:50
Definition: keyboard.h:294
Definition: dialogs.h:174
Action always.
Definition: dialogs.h:183
Action if a radio button is selected.
Definition: dialogs.h:182
Definition: dialogs.h:243
Radio button group - 1 is selectable at a time. Action on double click.
Definition: dialogs.h:181
Definition: dialogs.h:167
int HPOLYGON
Definition: dw.h:34