00001 /* ResidualVM - A 3D game interpreter 00002 * 00003 * ResidualVM is the legal property of its developers, whose names 00004 * are too numerous to list here. Please refer to the AUTHORS 00005 * file distributed with this source distribution. 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 * 00021 */ 00022 00023 #ifndef INVENTORY_H_ 00024 #define INVENTORY_H_ 00025 00026 #include "common/list.h" 00027 #include "common/memstream.h" 00028 #include "common/rect.h" 00029 00030 #include "engines/myst3/gfx.h" 00031 00032 #include "video/bink_decoder.h" 00033 00034 namespace Myst3 { 00035 00036 class Myst3Engine; 00037 class Texture; 00038 00039 class Inventory : public Window { 00040 public: 00041 Inventory(Myst3Engine *vm); 00042 virtual ~Inventory(); 00043 00044 // Window API 00045 Common::Rect getPosition() const override; 00046 Common::Rect getOriginalPosition() const override; 00047 00048 void loadFromState(); 00049 void updateState(); 00050 00051 void addItem(uint16 var, bool atEnd); 00052 void addSaavedroChapter(uint16 var); 00053 void addAll(); 00054 void removeItem(uint16 var); 00055 void reset(); 00056 00058 bool isMouseInside(); 00059 00061 void updateCursor(); 00062 00063 void reflow(); 00064 00065 uint16 hoveredItem(); 00066 void useItem(uint16 var); 00067 00068 void draw() override; 00069 00070 private: 00071 struct InventoryItem { 00072 uint16 var; 00073 Common::Rect rect; 00074 }; 00075 00076 typedef Common::List<InventoryItem> ItemList; 00077 00078 struct ItemData { 00079 uint16 textureX; 00080 uint16 textureWidth; 00081 uint16 textureHeight; 00082 uint16 var; 00083 }; 00084 00085 static const ItemData _availableItems[8]; 00086 const ItemData &getData(uint16 var); 00087 00088 Myst3Engine *_vm; 00089 00090 Texture *_texture; 00091 ItemList _inventory; 00092 00093 void initializeTexture(); 00094 00095 bool hasItem(uint16 var); 00096 00097 void openBook(uint16 age, uint16 room, uint16 node); 00098 void closeAllBooks(); 00099 }; 00100 00101 class DragItem : public Drawable { 00102 public: 00103 DragItem(Myst3Engine *vm, uint id); 00104 ~DragItem(); 00105 void drawOverlay() override; 00106 void setFrame(uint16 frame); 00107 00108 private: 00109 Myst3Engine *_vm; 00110 00111 Common::MemoryReadStream *_movieStream; 00112 Video::BinkDecoder _bink; 00113 00114 uint16 _frame; 00115 Texture *_texture; 00116 00117 Common::Rect getPosition(); 00118 }; 00119 00120 } // End of namespace Myst3 00121 00122 #endif // INVENTORY_H_