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