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