ScummVM API documentation
intrface.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  * Based on the original sources
22  * Faery Tale II -- The Halls of the Dead
23  * (c) 1993-1996 The Wyrmkeep Entertainment Co.
24  */
25 
26 #ifndef SAGA2_INTRFACE_H
27 #define SAGA2_INTRFACE_H
28 
29 #include "saga2/button.h"
30 #include "saga2/modal.h"
31 #include "saga2/player.h"
32 
33 namespace Saga2 {
34 
35 /* ===================================================================== *
36  Prototypes
37  * ===================================================================== */
38 
39 // notes: the load/unload resource functions are to be fazed out in lieu of
40 // the newer image cache object which will handle duplicate images without
41 // all the unwieldly calls
42 
43 // the appfunc helper functions will eventually be merged into an object
44 // that will handle all of the trasitive portion of the UI.
45 
46 void SetupUserControls();
47 void CleanupButtonImages();
48 void CleanupUserControls();
49 void SetupContainerViews(ContainerWindow *viewWindow);
50 void **loadButtonRes(hResContext *con, int16 resID, int16 numRes);
51 void **loadButtonRes(hResContext *con, int16 resID, int16 numRes, char a, char b, char c);
52 void **loadImageRes(hResContext *con, int16 resID, int16 numRes, char a, char b, char c);
53 void unloadImageRes(void **images, int16 numRes);
54 bool isIndivMode();
55 
56 // temp >>>
57 uint16 getPlayerActorWeightRatio(PlayerActor *player, uint16 &maxRatio, bool bReturnMaxRatio);
58 uint16 getPlayerActorBulkRatio(PlayerActor *player, uint16 &maxRatio, bool bReturnMaxRatio);
59 template< class T > inline T GetRatio(T curUnits, T maxUnits, T ratio);
60 uint16 getBulkRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio);
61 uint16 getWeightRatio(GameObject *obj, uint16 &maxRatio, bool bReturnMaxRatio);
62 void GetTotalMassBulk(GameObject *obj, uint16 &totalMass, uint16 &totalBulk);
63 
64 // appfunc helpers
65 void setIndivBtns(uint16 broNum);
66 void setTrioBtns();
67 void setCenterBtns(uint16 whichBrother);
68 void setControlPanelsToIndividualMode(uint16 whichBrother);
69 void setControlPanelsToTrioMode();
70 void setCenterBrother(uint16 whichBrother);
71 void toggleBrotherBanding(uint16 whichBrother);
72 uint16 translatePanID(uint16 ID);
73 void updateBrotherPortrait(uint16 brotherID, int16 pType);
74 void updateBrotherAggressionButton(uint16 brotherID, bool aggressive);
75 void updateBrotherBandingButton(uint16 brotherID, bool banded);
76 void updateBrotherRadioButtons(uint16 brotherID);
77 void updateReadyContainers();
78 void updateBrotherArmor(uint16 brotherID);
79 
80 void updateAllUserControls();
81 void updateBrotherControls(PlayerActorID brotherID);
82 void enableUserControls();
83 void disableUserControls();
84 
85 bool isBrotherDead(PlayerActorID brotherID);
86 
87 // update functions
88 void updateIndicators();
89 
90 void initUIState();
91 void saveUIState(Common::OutSaveFile *outS);
92 void loadUIState(Common::InSaveFile *in);
93 void cleanupUIState();
94 
95 // Varargs function to write to the status line.
96 void StatusMsg(const char *msg, ...); // frametime def
97 
98 
99 const uint32 faceGroupID = MKTAG('F', 'A', 'C', 'E');
100 const uint32 mentGroupID = MKTAG('C', 'O', 'N', 'T');
101 
102 
103 /* ===================================================================== *
104  Consts
105  * ===================================================================== */
106 
107 
108 /* ===================================================================== *
109  Exports
110  * ===================================================================== */
111 extern uint16 indivBrother;
112 
113 /* ===================================================================== *
114  Class forword Declarations
115  * ===================================================================== */
116 
117 class CPlaqText;
118 class CTextWindow;
119 class gTextBox;
120 class CPortrait;
121 
122 /* ===================================================================== *
123  User controls
124  * ===================================================================== */
125 
126 // control button state structure
127 struct BtnCtrlState {
128  bool aggress;
129  bool jump;
130  bool center;
131  bool banding;
132  int16 star;
133 };
134 
135 // name resource structure
136 struct ResName {
137  char a;
138  char b;
139  char c;
140  char d;
141 };
142 
143 enum uiBrotherName {
144  kUiJulian = 0,
145  kUiPhillip,
146  kUiKevin,
147  kUiIndiv
148 };
149 
150 // compressed button resource indexes
151 const int16 kAggressResNum = 0;
152 const int16 kJumpResNum = 6;
153 const int16 kCenterResNum = 4;
154 const int16 kBandingResNum = 2;
155 const int16 kMenConBtnResNum = 18;
156 const int16 kMassBulkResNum = 0;
157 const int16 kPieIndResNum = 0;
158 const int16 kJulBtnResNum = 22;
159 const int16 kPhiBtnResNum = 24;
160 const int16 kKevBtnResNum = 26;
161 const int16 kOptBtnResNum = 20;
162 
163 
164 
165 // standard number of images for push-buttons
166 const int16 kNumBtnImages = 2;
167 
168 // standard number of images for portraits
169 const uint16 kNumPortImages = 8;
170 
171 // number for pie indicators
172 const uint16 kNumPieIndImages = 16;
173 
174 // object pointers
175 extern CPortrait *Portrait;
176 
177 /* ===================================================================== *
178  Text Gadgets
179  * ===================================================================== */
180 
181 // plaq text writing class
182 class CPlaqText : public gControl {
183 protected:
184 
185  enum {
186  kBufSize = 128
187  };
188 
189 
190  char _lineBuf[kBufSize]; // text to render on button
191  textPallete _textFacePal; // contains info about coloring for multi-depth text rendering
192  Rect16 _textRect; // rect for the text
193  int16 _textPosition;
194  gFont *_buttonFont; // pointer to font for this button
195  gFont *_oldFont;
196 
197 public:
198 
199  CPlaqText(gPanelList &, const Rect16 &, const char *, gFont *,
200  int16, textPallete &, int16, AppFunc *cmd = NULL);
201 
202  void enable(bool);
203  void invalidate(Rect16 *unused = nullptr);
204 
205  void draw();
206  virtual void drawClipped(gPort &,
207  const Point16 &,
208  const Rect16 &);
209 
210 };
211 
212 
213 /* ===================================================================== *
214  CStatusLine: Status text object, child of CPlaqText
215  * ===================================================================== */
216 
217 
218 // takes a string and displays it in the status for
219 // a length of time, and then disappears
220 class CStatusLine : public CPlaqText {
221 private:
222 
223  Alarm _waitAlarm,
224  _minWaitAlarm;
225 
226  struct {
227  char *text;
228  uint32 frameTime;
229  } _lineQueue[12];
230 
231  uint8 _queueHead,
232  _queueTail;
233  bool _lineDisplayed;
234 
235  static uint8 bump(uint8 i) {
236  return (i + 1) % 12;
237  }
238 
239 public:
240  CStatusLine(gPanelList &, const Rect16 &, const char *, gFont *,
241  int16, textPallete, int32, int16, AppFunc *cmd = NULL);
242  ~CStatusLine();
243 
244  void setLine(char *, uint32 frameTime);
245  void experationCheck();
246 
247  void clear();
248 };
249 
250 
251 /* ===================================================================== *
252  Portrait control class
253  * ===================================================================== */
254 
255 enum PortraitType {
256  kPortraitNormal,
257  kPortraitAngry,
258  kPortraitConfused,
259  kPortraitOuch,
260  kPortraitSick,
261  kPortraitWounded,
262  kPortraitAsleep,
263  kPortraitDead
264 };
265 
266 class CPortrait {
267 private:
268  PortraitType _currentState[kNumViews + 1];
269  uint16 _numButtons;
270  uint16 _numViews;
271  GfxMultCompButton **_buttons;
272  GfxMultCompButton *_indivButton;
273 
274  void setPortrait(uint16);
275 
276 public:
277  // button array, number of buttons per view, num views
278  CPortrait(GfxMultCompButton *[], GfxMultCompButton *, const uint16, uint16);
279 
280  void ORset(uint16, PortraitType type);
281  void set(uint16 brotherID, PortraitType type);
282  PortraitType getCurrentState(uint16 brotherID) {
283  return _currentState[brotherID];
284  }
285  void getStateString(char buf[], int8 size, uint16 brotherID);
286 };
287 
288 
289 /* ===================================================================== *
290  CInterface: Class that handles indicators for the interface
291  * ===================================================================== */
292 
294 private:
295  GameObject *_containerObject;
296 
297 public:
298  static bool _bRedraw;
299 
300 private:
301  enum {
302  // background image coords
303  kBackImageXSize = 88,
304  kBackImageYSize = 43,
305 
306  // pie image coords
307  kMassPieXOffset = 8,
308  kMassPieYOffset = 9,
309  kBulkPieXOffset = 53,
310  kBulkPieYOffset = 9,
311  kPieXSize = 28,
312  kPieYSize = 26
313  };
314 
315  // xy positions of this indicator
316  Point16 _backImagePos;
317  Point16 _massPiePos;
318  Point16 _bulkPiePos;
319 
320  // memory for update
321  uint16 _currentMass;
322  uint16 _currentBulk;
323 
324  // resource context pointer
325  hResContext *_containerRes;
326 
327  // indicator images
328  void *_massBulkImag;
329 
330  // array of pointers to images
331  void **_pieIndImag;
332 
333  // image control buttons
334  GfxCompImage *_pieMass;
335  GfxCompImage *_pieBulk;
336 
337 
338 public:
339  void invalidate(Rect16 *unused = nullptr) {
340  _pieMass->invalidate();
341  _pieBulk->invalidate();
342  }
343 
344  CMassWeightIndicator(gPanelList *, const Point16 &, uint16 type = 1, bool death = false);
346 
347  uint16 getMassPieDiv() {
348  return _pieMass->getMax();
349  }
350  uint16 getBulkPieDiv() {
351  return _pieBulk->getMax();
352  }
353 
354  void setMassPie(uint16 val) {
355  _pieMass->setCurrent(val);
356  }
357  void setBulkPie(uint16 val) {
358  _pieBulk->setCurrent(val);
359  }
360  void recalculate();
361  static void update();
362 };
363 
364 
365 class CManaIndicator : public GfxCompImage {
366 public:
367 
368  // sizes of the mana star images
369  enum startSize {
370  kStar1XSize = 10,
371  kStar1YSize = 9,
372  kStar2XSize = 16,
373  kStar2YSize = 15,
374  kStar3XSize = 20,
375  kStar3YSize = 19,
376  kStar4XSize = 28,
377  kStar4YSize = 27,
378  kStar5XSize = 32,
379  kStar5YSize = 31,
380  kStar6XSize = 36,
381  kStar6YSize = 35,
382  kStar7XSize = 46,
383  kStar7YSize = 45
384  };
385 
386  // sizes of the rings
387  enum ringSize {
388  kRing1XSize = 8,
389  kRing1YSize = 7,
390  kRing2XSize = 12,
391  kRing2YSize = 11,
392  kRing3XSize = 16,
393  kRing3YSize = 15,
394  kRing4XSize = 22,
395  kRing4YSize = 21,
396  kRing5XSize = 26,
397  kRing5YSize = 25,
398  kRing6XSize = 32,
399  kRing6YSize = 31,
400  kRing7XSize = 40,
401  kRing7YSize = 39
402  };
403 
404  // area of control
405  enum area {
406  kAreaX = 475,
407  kAreaY = 315,
408  kAreaXSize = 152,
409  kAreaYSize = 135
410  };
411 
412  // coordinates
413  enum {
414  kCenterX = kAreaX + kAreaXSize / 2,
415  kCenterY = kAreaY + kAreaYSize / 2,
416  kWellXSize = 108,
417  kWellYSize = 123,
418  kWellX = (kAreaXSize / 2 - kWellXSize / 2) + 1,
419  kWellY = kAreaYSize / 2 - kWellYSize / 2
420  };
421 
422  // manas end points
423 
424  enum manaEndCoordsBase { // based on quadrants
425  kManaXOffset = 9,
426  kManaYOffset = -10,
427 
428  kManaUpperLeftX = 16 + kManaXOffset,
429  kManaUpperLeftY = 45 + kManaYOffset,
430  kManaUpperMidX = 70 + kManaXOffset,
431  kManaUpperMidY = 13 + kManaYOffset,
432  kManaUpperRightX = 122 + kManaXOffset,
433  kManaUpperRightY = 45 + kManaYOffset,
434  kManaLowerLeftX = 16 + kManaXOffset,
435  kManaLowerLeftY = 106 + kManaYOffset,
436  kManaLowerMidX = 70 + kManaXOffset,
437  kManaLowerMidY = 135 + kManaYOffset,
438  kManaLowerRightX = 122 + kManaXOffset,
439  kManaLowerRightY = 106 + kManaYOffset
440  };
441 
442  enum manaEndCoords {
443  kManaRedEndX = kManaUpperLeftX, //a // these are just dup tags
444  kManaRedEndY = kManaUpperLeftY, //b
445  kManaOrangeEndX = kManaUpperMidX, //c
446  kManaOrangeEndY = kManaUpperMidY,
447  kManaYellowEndX = kManaUpperRightX, //d
448  kManaYellowEndY = kManaUpperRightY, //b
449  kManaGreenEndX = kManaLowerLeftX, //a
450  kManaGreenEndY = kManaLowerLeftY, //e
451  kManaBlueEndX = kManaLowerMidX, //c
452  kManaBlueEndY = kManaLowerMidY,
453  kManaVioletEndX = kManaLowerRightX, //d
454  kManaVioletEndY = kManaLowerRightY, //e
455  kManaNumXYCoords = 12,
456  kManaNumManaTypes = kManaNumXYCoords / 2
457  };
458 
459  // mana star display offset from well center
460  enum startOffset {
461  kManaStartOffset = 12
462  };
463 
464  // mana information
465  enum manainfo {
466  kManaMaxLevel = 200,
467  kManaNumManaRegions = kManaNumManaTypes
468  };
469 
470  // resource data
471  enum resourceInfo {
472  kResNumStars = 7,
473  kResNumRings = 7,
474  kResStarResNum = 0,
475  kResRingResNum = 0,
476  kResNumManaColors = 13
477  };
478 
479  // this describes a star
480  // ... via image number and position on screen
481  struct manaLineInfo {
482  Point16 starPos;
483  Point16 ringPos;
484  uint8 starImageIndex;
485  uint8 ringImageIndex;
486  };
487 
488 private:
489 
490  // resource handle
491  hResContext *_resContext;
492 
493  // array of image pointers
494  void **_starImages;
495  void **_ringImages;
496 
497  // background image pointer
498  void *_backImage;
499  void *_wellImage;
500 
501  // image maps
502  gPixelMap _savedMap;
503 
504  // array of manaLine infos for blitting
505  manaLineInfo _manaLines[kManaNumManaTypes];
506 
507  // array of ring and star end positions
508  // this is initialized via constructor
509  Point16 _starRingEndPos[kManaNumManaTypes];
510 
511  Point16 _starSizes[kResNumStars];
512  Point16 _ringSizes[kResNumRings];
513 
514  // these are checks against redundent updates
515  int32 _currentMana[kManaNumManaTypes], _currentBaseMana[kManaNumManaTypes];
516 protected:
517 
518  // these do line and position calculations
519  int16 bresLine(Point16 from, Point16 to);
520  Point16 bresLine(Point16 from, Point16 to, int16 steps);
521 
522  // this gets the star/ring positions and image indexes
523  void getManaLineInfo(uint16 index, int16 manaAmount, int16 baseManaAmount, manaLineInfo *info);
524 
525 public:
526  CManaIndicator(gPanelList &list);
527  ~CManaIndicator();
528 
529  // this updates the star and ring position info
530  bool update(PlayerActor *player);
531 
532  // checks to see if the mana indicator needs to draw
533  bool needUpdate(PlayerActor *player);
534 
535  // this method provides a rect for any of the six mana regions of the control
536  // region numbers:
537  // -------
538  // |0 1 2|
539  // |3 4 5|
540  // -------
541  Rect16 getManaRegionRect(int8 region);
542  int getNumManaRegions() {
543  return kManaNumManaRegions;
544  }
545 
546  // drawing routines
547  void draw();
548  virtual void drawClipped(gPort &, const Point16 &, const Rect16 &);
549 };
550 
551 /* ===================================================================== *
552  CHealthIndicator: Health star indicator
553  * ===================================================================== */
554 
556 private:
557 
558  static const char *_hintText;
559 
560  enum {
561  kHealthStarFrameResNum = 14,
562  kHealthStarFrameNum = 1,
563  kHealthStarStart = 0,
564  kHealthStarNum = 23,
565  kHealthStarInitial = 0,
566  kHealthStarLevels = 24,
567  kHealthNumControls = kNumViews
568  };
569 
570  enum {
571  kHealthStarXPos = 572,
572  kHealthStarYPos = 21,
573  kHealthStarXSize = 32,
574  kHealthStarYSize = 32,
575  kHealthStarYOffset = 150,
576  kHealthFrameXPos = 571,
577  kHealthFrameYPos = 20,
578  kHealthFrameXSize = 32,
579  kHealthFrameYSize = 32
580  };
581 
582  // resource handle
583  hResContext *_healthRes;
584 
585  // buttons
586  GfxCompImage *_starBtns[kHealthNumControls];
587  GfxCompImage *_indivStarBtn;
588 
589  // array of pointer to the star imagery
590  void **_starImag;
591 
592  // health star frame imagery
593  void *_starFrameImag;
594 
595  void updateStar(GfxCompImage *starCtl, int32 bro, int32 baseVitality, int32 curVitality);
596 
597 public:
598  uint16 _starIDs[3];
599  int16 _imageIndexMemory[4];
600 
601 public:
602 
603  CHealthIndicator(AppFunc *cmd);
604  ~CHealthIndicator();
605 
606 
607  void update();
608 };
609 
610 
611 /* ===================================================================== *
612  Global classes
613  * ===================================================================== */
614 
615 extern CStatusLine *StatusLine;
616 extern CMassWeightIndicator *MassWeightIndicator;
617 extern CHealthIndicator *HealthIndicator;
618 extern CManaIndicator *ManaIndicator;
619 
620 } // end of namespace Saga2
621 
622 #endif
Definition: button.h:54
Definition: intrface.h:555
Definition: savefile.h:54
Definition: intrface.h:365
Definition: actor.h:32
Definition: gdraw.h:56
Definition: intrface.h:293
Definition: gdraw.h:178
Definition: button.h:298
Definition: stream.h:745
Definition: hresmgr.h:98
Definition: intrface.h:481
Definition: intrface.h:266
Definition: rect.h:42
Definition: panel.h:255
Definition: intrface.h:220
Definition: intrface.h:136
Definition: intrface.h:127
Definition: objects.h:118
Definition: player.h:43
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: gdraw.h:111
Definition: intrface.h:182
Definition: button.h:96
Definition: rect.h:290
Definition: fta.h:132
Definition: panel.h:406