ScummVM API documentation
hud.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 #include "twp/gfx.h"
23 #include "twp/object.h"
24 #include "twp/scenegraph.h"
25 
26 #define MAX_VERBS 22
27 #define NUMACTORS 6
28 
29 #ifndef TWP_HUD_H
30 #define TWP_HUD_H
31 
32 namespace Twp {
33 
34 struct VerbUiColors {
35  Color sentence;
36  Color verbNormal;
37  Color verbNormalTint;
38  Color verbHighlight;
39  Color verbHighlightTint;
40  Color dialogNormal;
41  Color dialogHighlight;
42  Color inventoryFrame;
43  Color inventoryBackground;
44  Color retroNormal;
45  Color retroHighlight;
46 
47  VerbUiColors();
48  VerbUiColors(const Color &s, const Color &vbNormal, const Color &vbNormalTint, const Color &vbHiglight, const Color &vbHiglightTint, const Color &dlgNormal, const Color &dlgHighlt, const Color &invFrame, const Color &inventoryBack, const Color &retroNml, const Color &retroHighlt);
49 };
50 
51 struct Verb {
52  VerbId id;
53  Common::String image;
54  Common::String fun;
55  Common::String text;
56  Common::String key;
57  int flags = 0;
58 
59  Verb();
60  Verb(VerbId id, const Common::String &image, const Common::String &fun, const Common::String &text, const Common::String &key, int flags = 0);
61 };
62 
63 struct VerbSlot {
64  Verb _verb;
65  float _shakeTime = 0.f;
67  Math::Vector2d _shakeOffset;
68  bool _over = false;
69  bool _hightlight = false;
70 
71  VerbSlot() {}
72  VerbSlot(Verb verb) : _verb(verb) {}
73 };
74 
75 struct ActorSlot {
76 public:
77  VerbUiColors verbUiColors;
78  VerbSlot verbSlots[MAX_VERBS];
79  bool selectable = false;
81 
82 public:
83  ActorSlot();
84 
85  Verb *getVerb(int id) {
86  for (auto &verbSlot : verbSlots) {
87  if (verbSlot._verb.id.id == id) {
88  return &verbSlot._verb;
89  }
90  }
91  return nullptr;
92  }
93 };
94 
95 class Hud;
96 struct VerbRect {
97  Hud *hud;
98  int index;
99 };
100 
101 class HudShader : public Shader {
102 public:
103  HudShader();
104  ~HudShader() override;
105 
106  void init();
107 
108 private:
109  void applyUniforms() final;
110 
111 public:
112  Color _shadowColor;
113  Color _normalColor;
114  Color _highlightColor;
115 };
116 
117 class Hud : public Node {
118 public:
119  Hud();
120 
121  void init();
122  ActorSlot *actorSlot(Common::SharedPtr<Object> actor);
123  bool isOverVerbs() const { return _over; }
124  void update(float elapsed, const Math::Vector2d &pos, Common::SharedPtr<Object> hotspot, bool mouseClick);
125 
126  void setVisible(bool visible) override;
127  void selectVerb(const Verb &verb);
128 
129  Math::Vector2d getVerbPos(const VerbSlot &verbSlot) const;
130 
131 private:
132  void drawCore(const Math::Matrix4 &trsf) final;
133  void drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &trsf);
134 
135 public:
136  ActorSlot _actorSlots[NUMACTORS];
138  Verb _verb;
139  HudShader _shader;
140  Math::Vector2d _mousePos;
141  bool _mouseClick = false;
142  bool _over = false;
143  int _defaultVerbId = 0;
144  float _fadeTime = 0.f;
145  bool _fadeIn = false;
146  bool _active = false;
147 };
148 } // namespace Twp
149 
150 #endif
Definition: hud.h:51
Definition: str.h:59
Definition: hud.h:96
Definition: object.h:78
Definition: hud.h:101
Definition: hud.h:75
Definition: ptr.h:572
Definition: gfx.h:35
Definition: hud.h:63
Definition: hud.h:34
Definition: hud.h:117
Definition: scenegraph.h:41
Definition: ptr.h:159
Definition: gfx.h:127
Definition: gfx.h:101
Definition: achievements_tables.h:27
Definition: spritesheet.h:37