ScummVM API documentation
scummui.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_SCUMMUI_H
23 #define MACS2_SCUMMUI_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 
36 class ScummUI {
37 public:
38  ScummUI(View1 *view);
39 
40  void draw(Graphics::ManagedSurface &s);
41  bool handleClick(const Common::Point &pos, bool scriptsRunning = false);
42  void handleMouseMove(const Common::Point &pos);
43  bool isPointInUI(const Common::Point &pos) const;
44  void updateSentenceLine(const Common::String &objectName);
45  void clearSentenceObject();
46  void syncInventory();
47  void syncActiveVerbFromCursorMode();
48  void resetInventoryAfterLoad();
49 
50 private:
51  static constexpr int kSentenceH = 14;
52  static constexpr int kUITop = kGameHeight;
53  static constexpr int kSentenceY = kGameHeight;
54  static constexpr int kVerbY = kGameHeight + kSentenceH;
55  static constexpr int kVerbW = 64;
56  static constexpr int kVerbH = 25;
57  static constexpr int kVerbCols = 2;
58  static constexpr int kVerbRows = 2;
59  static constexpr int kInvX = 128;
60  static constexpr int kInvItemW = 34;
61  static constexpr int kInvItemH = 25;
62  static constexpr int kInvIconInset = 1;
63  static constexpr int kInvCols = 4;
64  static constexpr int kInvRows = 2;
65 
66  struct VerbDef {
67  const char *label;
68  Script::MouseMode mode;
69  };
70  static const VerbDef kVerbs[4];
71 
72  void drawSentenceLine(Graphics::ManagedSurface &s);
73  void drawVerbBar(Graphics::ManagedSurface &s);
74  void drawInventoryStrip(Graphics::ManagedSurface &s);
75  void drawScrollButton(Graphics::ManagedSurface &s, const Common::Rect &rect, int iconResourceIndex, bool hovered);
76  void drawUIButton(const Common::Rect &rect, bool pressed, Graphics::ManagedSurface &s);
77  void rebuildProtagonistItems();
78 
79  int getScrollButtonWidth() const;
80  int getInvArrowX() const;
81 
82  Common::Array<GameObject *> getProtagonistItems() const;
83 
84  Common::Rect getVerbRect(int index) const;
85  Common::Rect getInvItemRect(int index) const;
86  Common::Rect getInvScrollLeftRect() const;
87  Common::Rect getInvScrollRightRect() const;
88 
89  View1 *_view;
90  int _activeVerbIndex;
91  int _hoveredVerb;
92  int _hoveredItemIndex;
93  int _hoveredScrollButton;
94  int _inventoryScrollOffset;
95  Common::Array<GameObject *> _protagonistItems;
96  Common::String _sentenceObject;
97 };
98 
99 } // namespace Macs2
100 
101 #endif // MACS2_SCUMMUI_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: array.h:52
Definition: rect.h:536
Definition: view1.h:188
Definition: rect.h:144
Definition: scummui.h:36
Definition: debugtools.h:25