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