ScummVM API documentation
actionbar.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 MACS2_ACTIONBAR_H
23 #define MACS2_ACTIONBAR_H
24 
25 #include "common/rect.h"
26 #include "common/str.h"
27 #include "graphics/managed_surface.h"
28 #include "macs2/macs2_constants.h"
29 #include "macs2/scriptexecutor.h"
30 
31 namespace Macs2 {
32 
33 class View1;
34 class GameObject;
35 struct AnimFrame;
36 struct HudButton;
37 
42 class ActionBar {
43 public:
44  ActionBar(View1 *view);
45 
46  void draw(Graphics::ManagedSurface &s);
47  bool handleClick(const Common::Point &pos, bool scriptsRunning = false);
48  void handleMouseMove(const Common::Point &pos);
49  bool isPointInUI(const Common::Point &pos) const;
50  void updateSentenceLine(const Common::String &objectName);
51  void clearSentenceObject();
52  void syncInventory();
53  void syncActiveVerbFromCursorMode();
54  void resetInventoryAfterLoad();
55 
56  bool useScummSkin() const;
57  bool useNativeSkin() const;
59  int gameAreaBottomY() const;
60 
61 private:
62  static constexpr int kSentenceH = 14;
63  static constexpr int kUITop = kGameHeight;
64  static constexpr int kSentenceY = kGameHeight;
65  static constexpr int kVerbY = kGameHeight + kSentenceH;
66  static constexpr int kVerbW = 64;
67  static constexpr int kVerbH = 25;
68  static constexpr int kVerbCols = 2;
69  static constexpr int kVerbRows = 2;
70  static constexpr int kInvX = 128;
71  static constexpr int kInvItemW = 34;
72  static constexpr int kInvItemH = 25;
73  static constexpr int kInvIconInset = 1;
74  static constexpr int kInvCols = 4;
75  static constexpr int kInvRows = 2;
76 
77  struct VerbDef {
78  const char *label;
79  Script::MouseMode mode;
80  };
81  static const VerbDef kVerbs[4];
82 
83  // --- Scumm skin ---
84  void drawScumm(Graphics::ManagedSurface &s);
85  bool handleClickScumm(const Common::Point &pos, bool scriptsRunning);
86  void handleMouseMoveScumm(const Common::Point &pos);
87  void drawSentenceLine(Graphics::ManagedSurface &s);
88  void drawVerbBar(Graphics::ManagedSurface &s);
89  void drawInventoryStrip(Graphics::ManagedSurface &s);
90  void drawScrollButton(Graphics::ManagedSurface &s, const Common::Rect &rect, int iconResourceIndex, bool hovered);
91  void drawUIButton(const Common::Rect &rect, bool pressed, Graphics::ManagedSurface &s);
92  void rebuildProtagonistItems();
93 
94  int getScrollButtonWidth() const;
95  int getInvArrowX() const;
96 
97  Common::Array<GameObject *> getProtagonistItems() const;
98 
99  Common::Rect getVerbRect(int index) const;
100  Common::Rect getInvItemRect(int index) const;
101  Common::Rect getInvScrollLeftRect() const;
102  Common::Rect getInvScrollRightRect() const;
104  bool isPointInInventoryStrip(const Common::Point &pos) const;
105 
106  // --- Native skin (megapic + HudButton table) ---
107  void drawNative(Graphics::ManagedSurface &s);
108  bool handleClickNative(const Common::Point &pos);
109  void handleMouseMoveNative(const Common::Point &pos);
110  void refreshSaveSlotNames();
111  Common::String buildNativeSentenceLine() const;
112  const HudButton *findHudButtonAt(const Common::Point &pos, int *outIndex = nullptr) const;
113 
114  View1 *_view;
115  int _activeVerbIndex;
116  int _hoveredVerb;
117  int _hoveredItemIndex;
118  int _hoveredScrollButton;
119  int _inventoryScrollOffset;
120  Common::Array<GameObject *> _protagonistItems;
121  Common::String _sentenceObject;
122 
123  uint16 _hoveredButtonId = 0;
124  uint16 _pressedButtonId = 0;
125 };
126 
127 } // namespace Macs2
128 
129 #endif // MACS2_ACTIONBAR_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: macs2.h:126
Definition: array.h:52
Definition: rect.h:536
Definition: view1.h:188
int gameAreaBottomY() const
Definition: rect.h:144
Definition: actionbar.h:31
Definition: actionbar.h:42