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
|
/* 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/>.
*
* Inventory related functions
*/
#ifndef TINSEL_INVENTORY_H // prevent multiple includes
#define TINSEL_INVENTORY_H
#include "tinsel/dw.h"
#include "tinsel/events.h" // for PLR_EVENT, PLR_EVENT
#include "tinsel/inv_objects.h"
#include "tinsel/object.h"
#include "tinsel/movers.h"
namespace Common {
class Serializer;
struct KeyState;
}
namespace Tinsel {
struct OBJECT;
struct FREEL;
struct FILM;
struct CONFINIT;
enum {
INV_OPEN = -1, // DW1 only
INV_CONV = 0,
INV_1 = 1,
INV_2 = 2,
DW0_INV_CONF = 3,
INV_MENU = 3, // DW2 constant
NUM_INV_V0 = 4,
// Discworld 2 constants
DW2_INV_OPEN = 5,
INV_DEFAULT = 6,
// Noir constants
INV_3 = 3,
INV_4 = 4,
NOIR_INV_CONF = 5,
NUM_INV_V3 = 6,
INV_7NOINV = 7,
INV_8NOINV = 8,
INV_NOTEBOOK = 9,
MAX_NUM_INV = NUM_INV_V3 // For determination of _invD array size
};
#define INV_CONF ((TinselVersion == 3) ? NOIR_INV_CONF : DW0_INV_CONF)
#define NUM_INV ((TinselVersion == 3) ? NUM_INV_V3 : NUM_INV_V0)
enum {
NOOBJECT = -1,
INV_NOICON_V0 = -1,
INV_CLOSEICON = -2,
INV_OPENICON = -3,
INV_HELDNOTIN_V0 = -4,
// Noir discerns between NOOBJECT and INV_NOICON
INV_NOICON_V3 = 0,
INV_HELDNOTIN_V3 = 1,
INV_HELDIN = 2,
};
#define INV_NOICON ((TinselVersion == 3) ? INV_NOICON_V3 : INV_NOICON_V0)
#define INV_HELDNOTIN ((TinselVersion == 3) ? INV_HELDNOTIN_V3 : INV_HELDNOTIN_V0)
enum CONV_PARAM {
CONV_DEF,
CONV_BOTTOM,
CONV_END,
CONV_TOP
};
enum InventoryType { EMPTY,
FULL,
CONF };
enum InvCursorFN { IC_AREA,
IC_DROP };
#define sliderRange (_sliderYmax - _sliderYmin)
#define MAXSLIDES 4
#define MAX_PERMICONS 10 // Max permanent conversation icons
#define MAXHICONS 10 // Max dimensions of
#define MAXVICONS 6 // an inventory window
#define SG_DESC_LEN 40 // Max. saved game description length
// Number of objects that makes up an empty window
#define MAX_WCOMP_T0 21 // 4 corners + (3+3) sides + (2+2) extra sides
// + Bground + title + slider
// + more Needed for save game window
#define MAX_WCOMP_T3 84
#define MAX_WCOMP (TinselVersion == 3 ? MAX_WCOMP_T3 : MAX_WCOMP_T0)
#define MAX_ICONS MAXHICONS *MAXVICONS
#define MAX_ININV_TOT 160
enum CONFTYPE {
MAIN_MENU,
SAVE_MENU,
LOAD_MENU,
QUIT_MENU,
RESTART_MENU,
SOUND_MENU,
CONTROLS_MENU,
SUBTITLES_MENU,
HOPPER_MENU1,
HOPPER_MENU2,
TOP_WINDOW
};
struct INV_DEF {
int MinHicons; // }
int MinVicons; // } Dimension limits
int MaxHicons; // }
int MaxVicons; // }
int NoofHicons; // }
int NoofVicons; // } Current dimentsions
int contents[160]; // Contained items
int NoofItems; // Current number of held items
int FirstDisp; // Index to first item currently displayed
int inventoryX; // } Display position
int inventoryY; // }
int otherX; // } Display position
int otherY; // }
int MaxInvObj; // Max. allowed contents
SCNHANDLE hInvTitle; // Window heading
bool resizable; // Re-sizable window?
bool bMoveable; // Moveable window?
int sNoofHicons; // }
int sNoofVicons; // } Current dimensions
bool bMax; // Maximised last time open?
};
//----- Data pertinant to scene hoppers ------------------------
struct HOPPER {
uint32 hScene;
SCNHANDLE hSceneDesc;
uint32 numEntries;
uint32 entryIndex;
};
struct HOPENTRY {
uint32 eNumber; // entrance number
SCNHANDLE hDesc; // handle to entrance description
uint32 flags;
};
enum BTYPE {
RGROUP, ///< Radio button group - 1 is selectable at a time. Action on double click
ARSBUT, ///< Action if a radio button is selected
AABUT, ///< Action always
AATBUT, ///< Action always, text box
ARSGBUT,
AAGBUT, ///< Action always, graphic button
SLIDER, ///< Not a button at all
TOGGLE, ///< Discworld 1 toggle
TOGGLE1, ///< Discworld 2 toggle type 1
TOGGLE2, ///< Discworld 2 toggle type 2
DCTEST,
FLIP,
FRGROUP,
ROTATE,
NOTHING
};
enum BFUNC {
NOFUNC,
SAVEGAME,
LOADGAME,
IQUITGAME,
CLOSEWIN,
OPENLOAD,
OPENSAVE,
OPENREST,
OPENSOUND,
OPENCONT,
#ifndef JAPAN
OPENSUBT,
#endif
OPENQUIT,
INITGAME,
MUSICVOL,
HOPPER2, // Call up Scene Hopper 2
BF_CHANGESCENE,
CLANG,
RLANG
#ifdef MAC_OPTIONS
,
MASTERVOL,
SAMPVOL
#endif
};
enum TM { TM_POINTER,
TM_INDEX,
TM_STRINGNUM,
TM_UNK4,
TM_NONE };
// For slideSlider() and similar
enum SSFN {
S_START,
S_SLIDE,
S_END,
S_TIMEUP,
S_TIMEDN
};
struct CONFBOX {
BTYPE boxType;
BFUNC boxFunc;
TM textMethod;
char *boxText;
int ixText;
int xpos;
int ypos;
int w; // Doubles as max value for SLIDERs
int h; // Doubles as iteration size for SLIDERs
int *ival;
int bi; // Base index for AAGBUTs
};
// Data for button press/toggle effects
struct BUTTONEFFECT {
bool bButAnim;
CONFBOX *box;
bool press; // true = button press; false = button toggle
};
enum class SysReel;
class Dialogs {
public:
Dialogs();
virtual ~Dialogs();
void popUpInventory(int invno, int menuId = -1);
void openMenu(CONFTYPE menuType);
void xMovement(int x);
void yMovement(int y);
void eventToInventory(PLR_EVENT pEvent, const Common::Point &coOrds);
int whichItemHeld();
void holdItem(int item, bool bKeepFilm = false);
void dropItem(int item);
void clearInventory(int invno);
void addToInventory(int invno, int icon, bool hold = false);
bool remFromInventory(int invno, int icon);
void registerIcons(void *cptr, int num);
void idec_convw(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
void idec_inv1(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
void idec_inv2(SCNHANDLE text, int MaxContents, int MinWidth, int MinHeight,
int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
// Noir
Common::Array<int> getAllNotebookClues() const;
void idec_invMain(SCNHANDLE text, int MaxContents);
bool inventoryActive();
bool inventoryOrNotebookActive();
void permaConvIcon(int icon, bool bEnd = false);
void convPos(int bpos);
void convPoly(HPOLYGON hPoly);
int getIcon();
void closeDownConv();
void hideConversation(bool hide);
bool convIsHidden();
void convAction(int index);
void setConvDetails(CONV_PARAM fn, HPOLYGON hPoly, int ano);
void inventoryIconCursor(bool bNewItem);
void setInvWinParts(SCNHANDLE hf);
void setFlagFilms(SCNHANDLE hf);
void setConfigStrings(SCNHANDLE *tp);
int invItem(Common::Point &coOrds, bool update);
int invItem(int *x, int *y, bool update);
int invItemId(int x, int y);
int inventoryPos(int num);
bool isInInventory(int object, int invnum);
void killInventory();
void syncInvInfo(Common::Serializer &s);
int invGetLimit(int invno);
void invSetLimit(int invno, int MaxContents);
void invSetSize(int invno, int MinWidth, int MinHeight,
int StartWidth, int StartHeight, int MaxWidth, int MaxHeight);
bool getIsInvObject(int id);
int whichInventoryOpen();
bool isTopWindow();
bool menuActive();
bool isConvWindow();
const FILM *getObjectFilm(int object) const;
void setObjectFilm(int object, SCNHANDLE hFilm);
void callFunction(BFUNC boxFunc);
OBJECT *addObject(const FREEL *pfreel, int num);
void invPutDown(int index);
void slideMSlider(int x, SSFN fn);
void addBoxes(bool posnSlide);
void select(int i, bool force);
void fillInInventory();
void invCursor(InvCursorFN fn, int CurX, int CurY);
const InventoryObject *getInvObject(int id);
const InventoryObjectT3 *getInvObjectT3(int id);
void invPointEvent(const InventoryObject *invObj, int index);
bool updateString(const Common::KeyState &kbd);
bool inventoryIsActive() { return _inventoryState == ACTIVE_INV; }
bool isMixingDeskControl() { return _invDragging == ID_MDCONT; }
int currentInventoryX() { return _invD[_activeInv].inventoryX; }
int currentInventoryY() { return _invD[_activeInv].inventoryY; }
bool configurationIsActive() { return _activeInv == INV_CONF; }
bool displayObjectsActive() { return _objArray[0] != NULL; }
bool inventoryIsHidden() { return _InventoryHidden; }
const FILM *getWindowData();
void redraw();
// Noir
bool isConvAndNotMove();
bool _noLanguage;
int _glitterIndex;
volatile int _pointedWaitCount; // used by ObjectProcess - fix the 'repeated pressing bug'
// For editing save game names
char _saveGameDesc[SG_DESC_LEN + 2];
OBJECT *_iconArray[MAX_ICONS]; // Current display objects (icons)
BUTTONEFFECT _buttonEffect;
private:
int whichMenuBox(int curX, int curY, bool bSlides);
void confActionSpecial(int i);
bool rePosition();
bool languageChange();
void primeSceneHopper();
void freeSceneHopper();
void rememberChosenScene();
void setChosenScene();
void firstEntry(int first);
void hopAction();
void dumpIconArray();
void dumpDobjArray();
void dumpObjArray();
void firstScene(int first);
void firstFile(int first);
int getObjectIndex(int id) const;
void invSaveGame();
void invLoadGame();
int invArea(int x, int y);
void invBoxes(bool InBody, int curX, int curY);
void invLabels(bool InBody, int aniX, int aniY);
void adjustTop();
OBJECT *addInvObject(int num, const FREEL **pfreel, const FILM **pfilm);
void addBackground(OBJECT **rect, const Common::Rect &bounds, OBJECT **title = nullptr, int textFrom = 0);
void addTitle(OBJECT **title, const Common::Rect &rect);
void addSlider(OBJECT **slide, const FILM *pfilm);
void addBox(int *pi, const int i);
void addEWSlider(OBJECT **slide, const FILM *pfilm);
void positionInventory(OBJECT *pMultiObj, int xOffset, int yOffset, int zPosition);
int addExtraWindow(int x, int y, OBJECT **retObj);
void constructInventoryCommon(SysReel reel, bool hasTitle);
void constructConversationInventory();
void constructInventory(InventoryType filling);
void constructOtherInventory(int menuId);
void constructMainInventory();
void alterCursor(int num);
void setMenuGlobals(CONFINIT *ci);
void closeInventory();
int nearestSlideY(int fity);
void slideSlider(int y, SSFN fn);
void slideCSlider(int y, SSFN fn);
void gettingTaller();
void gettingShorter();
void gettingWider();
void gettingNarrower();
void changeingSize();
void invDragStart();
void invDragEnd();
bool menuDown(int lines);
bool menuUp(int lines);
void menuRollDown();
void menuRollUp();
void menuPageDown();
void menuPageUp();
void inventoryDown();
void inventoryUp();
void menuAction(int i, bool dbl);
void invPickup(int index);
void invWalkTo(const Common::Point &coOrds);
void invAction();
void invLook(const Common::Point &coOrds);
void idec_inv(int num, SCNHANDLE text, int MaxContents,
int MinWidth, int MinHeight,
int StartWidth, int StartHeight,
int MaxWidth, int MaxHeight,
int startx, int starty, bool moveable);
//----- Permanent data (set once) -----
SCNHANDLE _flagFilm; // Window members and cursors' graphic data
SCNHANDLE _configStrings[20];
INV_DEF _invD[MAX_NUM_INV]; // Conversation + 2 inventories + ...
int _activeInv; // Which inventory is currently active
InventoryObjects *_invObjects; // Inventory objects' data
SCNHANDLE *_invFilms;
DIRECTION _initialDirection;
//----- Permanent data (updated, valid while inventory closed) -----
int _heldItem; // Current held item
SCNHANDLE _heldFilm;
SCNHANDLE _hWinParts; // Window members and cursors' graphic data
// Permanent contents of conversation inventory
int _permIcons[MAX_PERMICONS]; // Basic items i.e. permanent contents
int _numPermIcons; // - copy to conv. inventory at pop-up time
int _numEndIcons;
//----- Data pertinant to current active inventory -----
bool _InventoryHidden;
bool _InventoryMaximised;
bool _ItemsChanged; // When set, causes items to be re-drawn
int _SuppH; // 'Linear' element of
int _SuppV; // dimensions during re-sizing
int _yChange; //
int _yCompensate; // All to do with re-sizing.
int _xChange; //
int _xCompensate; //
bool _reOpenMenu;
int _TL, _TR, _BL, _BR; // Used during window construction
int _TLwidth, _TLheight; //
int _TRwidth; //
int _BLheight; //
LANGUAGE _displayedLanguage;
OBJECT *_objArray[MAX_WCOMP_T3]; // Current display objects (window)
OBJECT *_dispObjArray[MAX_WCOMP_T3]; // Current display objects (re-sizing window)
ANIM _iconAnims[MAX_ICONS];
OBJECT *_rectObject, *_slideObject; // Current display objects, for reference
// objects are in objArray.
int _sliderYpos; // For positioning the slider
int _sliderYmax, _sliderYmin; //
// Also to do with the slider
struct {
int n;
int y;
} _slideStuff[MAX_ININV_TOT + 1];
struct MDSLIDES {
int num;
OBJECT *obj;
int min, max;
};
MDSLIDES _mdSlides[MAXSLIDES];
int _numMdSlides;
// Icon clicked on to cause an event
// - Passed to conversation polygon or actor code via Topic()
// - (sometimes) Passed to inventory icon code via OtherObject()
int _thisIcon;
CONV_PARAM _thisConvFn; // Top, 'Middle' or Bottom
HPOLYGON _thisConvPoly; // Conversation code is in a polygon code block
int _thisConvActor; // ...or an actor's code block.
int _pointedIcon; // used by invLabels - icon pointed to on last call
int _sX; // used by slideMSlider() - current x-coordinate
int _lX; // used by slideMSlider() - last x-coordinate
bool _bMoveOnUnHide; // Set before start of conversation
// - causes conversation to be started in a sensible place
HOPPER *_pHopper;
HOPENTRY *_pEntries;
int _numScenes;
int _numEntries;
HOPPER *_pChosenScene;
int _lastChosenScene;
bool _bRemember;
enum { IC_NORMAL,
IC_DR,
IC_UR,
IC_TB,
IC_LR,
IC_INV,
IC_UP,
IC_DN } _invCursor;
enum { NO_INV,
IDLE_INV,
ACTIVE_INV,
BOGUS_INV } _inventoryState;
enum { ID_NONE,
ID_MOVE,
ID_SLIDE,
ID_BOTTOM,
ID_TOP,
ID_LEFT,
ID_RIGHT,
ID_TLEFT,
ID_TRIGHT,
ID_BLEFT,
ID_BRIGHT,
ID_CSLIDE,
ID_MDCONT } _invDragging;
};
void ObjectEvent(CORO_PARAM, int objId, TINSEL_EVENT event, bool bWait, int myEscape, bool *result = NULL);
} // End of namespace Tinsel
#endif /* TINSEL_INVENTRY_H */
|