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 public:
44  struct ItemDescription {
45  Common::String name; // 0x00
46  byte keepItem = kInvItemUseThenLose; // 0x14
47  Common::Rect sourceRect; // 0x16
48  };
49 
50  InventoryBox();
51 
52  void init() override;
53  void updateGraphics() override;
54  void registerGraphics() override;
55  void handleInput(NancyInput &input);
56 
57  void onScrollbarMove();
58 
59  void addItem(const int16 itemID);
60  void removeItem(const int16 itemID);
61  void onReorder();
62 
63  Common::Array<int16> &getOrder() { return _order; }
64 
65 private:
66  // These are private since they should only be called from Scene
67 
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 
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:524
Definition: input.h:41
Definition: ptr.h:572
Definition: soundequalizerpuzzle.h:27
Definition: renderobject.h:36
Definition: enginedata.h:113
Definition: inventorybox.h:44
Definition: actionmanager.h:32