ScummVM API documentation
inventorybox.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 
22 #ifndef NANCY_UI_INVENTORYBOX_H
23 #define NANCY_UI_INVENTORYBOX_H
24 
25 #include "common/ptr.h"
26 
27 #include "engines/nancy/time.h"
28 #include "engines/nancy/renderobject.h"
29 #include "engines/nancy/ui/scrollbar.h"
30 
31 namespace Nancy {
32 
33 class NancyEngine;
34 struct NancyInput;
35 
36 namespace State {
37 class Scene;
38 }
39 
40 namespace UI {
41 
42 class InventoryBox : public RenderObject {
43  friend class Nancy::State::Scene;
44 
45 public:
46  struct ItemDescription {
47  Common::String name; // 0x00
48  byte keepItem = kInvItemUseThenLose; // 0x14
49  Common::Rect sourceRect; // 0x16
50  };
51 
52  InventoryBox();
53 
54  void init() override;
55  void updateGraphics() override;
56  void registerGraphics() override;
57  void handleInput(NancyInput &input);
58 
59  void onScrollbarMove();
60 
61 private:
62  // These are private since they should only be called from Scene
63  void addItem(const int16 itemID);
64  void removeItem(const int16 itemID);
65 
66  void onReorder();
67  void setHotspots(const uint pageNr);
68  void drawItemInSlot(const uint itemID, const uint slotID, const bool highlighted = false);
69 
70  class Curtains : public RenderObject {
71  public:
72  Curtains();
73  virtual ~Curtains() = default;
74 
75  void init() override;
76  void updateGraphics() override;
77 
78  void setOpen(bool open) { _areOpen = open; }
79 
80  void setAnimationFrame(uint frame);
81 
82  uint _numFrames;
83  uint _curFrame;
84  Time _nextFrameTime;
85  bool _areOpen;
86  bool _soundTriggered;
87  };
88 
89  struct ItemHotspot {
90  int16 itemID = -1;
91  int itemOrder = -1; // index of the item into the _order array
92  Common::Rect hotspot; // in screen coordinates
93  };
94 
95  Graphics::ManagedSurface _iconsSurface;
96  Graphics::ManagedSurface _fullInventorySurface;
97 
99  Curtains _curtains;
100 
101  float _scrollbarPos;
102 
103  Common::Array<int16> _order;
104  ItemHotspot _itemHotspots[4];
105  int _highlightedHotspot;
106 
107  const struct INV *_inventoryData;
108 };
109 
110 } // End of namespace UI
111 } // End of namespace Nancy
112 
113 #endif // NANCY_UI_INVENTORYBOX_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: time.h:30
Definition: inventorybox.h:42
Definition: rect.h:524
Definition: input.h:41
Definition: ptr.h:572
Definition: soundequalizerpuzzle.h:27
Definition: renderobject.h:36
Definition: enginedata.h:108
Definition: inventorybox.h:46
Definition: scene.h:72
Definition: actionmanager.h:32