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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef ACCESS_INVENTORY_H 24 #define ACCESS_INVENTORY_H 25 26 #include "common/scummsys.h" 27 #include "common/array.h" 28 #include "common/rect.h" 29 #include "common/str-array.h" 30 #include "access/data.h" 31 #include "access/asurface.h" 32 33 namespace Access { 34 35 enum ItemState { 36 ITEM_NOT_FOUND = 0, ITEM_IN_INVENTORY = 1, ITEM_USED = 2 37 }; 38 39 class InventoryEntry { 40 public: 41 Common::String _name; 42 int _value; 43 44 int _otherItem1; 45 int _newItem1; 46 int _otherItem2; 47 int _newItem2; 48 49 void load(const Common::String &name, const int *data); 50 51 int checkItem(int itemId); 52 }; 53 54 class InventoryManager : public Manager { 55 struct SavedFields { 56 int _vWindowHeight; 57 int _vWindowLinesTall; 58 int _vWindowWidth; 59 int _vWindowBytesWide; 60 int _playFieldHeight; 61 int _playFieldWidth; 62 int _windowXAdd; 63 int _windowYAdd; 64 int _screenYOff; 65 int _scrollX; 66 int _scrollY; 67 int _clipWidth; 68 int _clipHeight; 69 Common::Point _bufferStart; 70 int _scrollCol; 71 int _scrollRow; 72 }; 73 private: 74 Common::Array<int> _items; 75 Common::Array<Common::Rect> _invCoords; 76 ASurface _savedBuffer1; 77 ASurface _savedScreen; 78 SavedFields _fields; 79 bool _iconDisplayFlag; 80 Common::Array<int> _tempLPtr; 81 Common::StringArray _tempLOff; 82 int _boxNum; 83 84 void savedFields(); 85 86 void restoreFields(); 87 88 void initFields(); 89 90 void getList(); 91 92 void showAllItems(); 93 94 void putInvIcon(int itemIndex, int itemId); 95 96 void chooseItem(); 97 98 void freeInvCells(); 99 100 int coordIndexOf(); 101 102 void saveScreens(); 103 104 void restoreScreens(); 105 106 void outlineIcon(int itemIndex); 107 108 void combineItems(); 109 110 void zoomIcon(int zoomItem, int backItem, int zoomBox, bool shrink); 111 public: 112 Common::Array<InventoryEntry> _inv; 113 int _startInvItem; 114 int _startInvBox; 115 bool _invChangeFlag; 116 bool _invRefreshFlag; 117 bool _invModeFlag; 118 int _startAboutItem; 119 int _startTravelItem; 120 public: 121 InventoryManager(AccessEngine *vm); 122 123 int &operator[](int idx); 124 125 int useItem(); 126 void setUseItem(int itemId); 127 128 void refreshInventory(); 129 130 int newDisplayInv(); 131 int displayInv(); 132 133 /** 134 * Synchronize savegame data 135 */ 136 void synchronize(Common::Serializer &s); 137 }; 138 139 } // End of namespace Access 140 141 #endif /* ACCESS_INVENTORY_H */ 142