ScummVM API documentation
toolbar.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 CRYOMNI3D_VERSAILLES_TOOLBAR_H
23 #define CRYOMNI3D_VERSAILLES_TOOLBAR_H
24 
25 #include "common/array.h"
26 #include "common/rect.h"
27 #include "graphics/managed_surface.h"
28 #include "graphics/surface.h"
29 
30 #include "cryomni3d/font_manager.h"
31 #include "cryomni3d/objects.h"
32 #include "cryomni3d/sprites.h"
33 
34 namespace CryOmni3D {
35 class CryOmni3DEngine;
36 
37 namespace Versailles {
38 
39 
40 class Toolbar {
41 public:
42  Toolbar() : _sprites(nullptr), _fontManager(nullptr), _inventory(nullptr),
43  _messages(nullptr), _engine(nullptr), _inventoryEnabled(true), _inventoryMaxOffset(0),
44  _inventoryOffset(0), _inventoryHovered(uint(-1)), _inventorySelected(uint(-1)), _backupSelectedObject(nullptr),
45  _mouseInOptions(false), _mouseInViewObject(false), _inventoryButtonDragging(false), _parentMustRedraw(false),
46  _shortExit(false), _position(60) { }
47  ~Toolbar();
48 
49  void init(const Sprites *sprites, FontManager *fontManager,
50  const Common::Array<Common::String> *messages, Inventory *inventory, CryOmni3DEngine *engine);
51 
52  Graphics::Surface &getBackgroundSurface() { return _bgSurface; }
53  bool displayToolbar(const Graphics::Surface *original);
54  void inventoryChanged(uint newPosition);
55  uint inventoryOffset() const { return _inventoryOffset; }
56  void setInventoryOffset(uint offset) { _inventoryOffset = offset; }
57  void setInventoryEnabled(bool enabled) { _inventoryEnabled = enabled; }
58 
59 private:
60  typedef uint(Toolbar::*ZoneCallback)(uint dragStatus);
61  struct Zone {
62  Common::Rect rect;
63  uint16 imageMain;
64  uint16 imageSecondary;
65  ZoneCallback callback;
66  bool secondary;
67  bool hidden;
68  };
69  Common::Array<Zone> _zones;
70  const Sprites *_sprites;
71  FontManager *_fontManager;
72  const Common::Array<Common::String> *_messages;
73  Inventory *_inventory;
74  CryOmni3DEngine *_engine;
75 
76  static const uint kTextOffset = 13;
77 
78  void addZone(uint16 cursorMainId, uint16 cursorSecondaryId, Common::Point position,
79  ZoneCallback callback);
80  void updateZones();
81  Common::Array<Zone>::const_iterator hitTestZones(const Common::Point &mousePos) const;
82  uint captureEvent(const Common::Point &mousePos, uint dragStatus);
83  void drawToolbar(const Graphics::Surface *original);
84  void handleToolbarEvents(const Graphics::Surface *original);
85 
86  bool _inventoryEnabled;
87  uint _inventoryMaxOffset;
88  uint _inventoryOffset;
89  uint _inventoryHovered;
90  uint _inventorySelected;
91 
92  Object *_backupSelectedObject;
93  bool _mouseInOptions;
94  bool _mouseInViewObject;
95  bool _inventoryButtonDragging;
96 
97  bool _parentMustRedraw;
98  bool _shortExit;
99  uint _position;
100 
101  Graphics::Surface _bgSurface;
102  Graphics::ManagedSurface _destSurface;
103 
104  template<uint N>
105  uint callbackInventory(uint dragStatus) { return callbackInventory(N, dragStatus); }
106  uint callbackInventory(uint invId, uint dragStatus);
107  uint callbackInventoryPrev(uint dragStatus);
108  uint callbackInventoryNext(uint dragStatus);
109  uint callbackViewObject(uint dragStatus);
110  uint callbackOptions(uint dragStatus);
111  uint callbackDocumentation(uint dragStatus);
112 };
113 
114 } // End of namespace Versailles
115 } // End of namespace CryOmni3D
116 
117 #endif
Definition: managed_surface.h:51
Definition: toolbar.h:40
Definition: cryomni3d.h:62
Definition: surface.h:67
Definition: objects.h:77
Definition: rect.h:144
Definition: font_manager.h:40
Definition: objects.h:33
const T * const_iterator
Definition: array.h:55
Definition: cryomni3d.h:80
Definition: rect.h:45
Definition: sprites.h:40