ScummVM API documentation
actorswitcher.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 TWP_ACTORSWITCHER_H
23#define TWP_ACTORSWITCHER_H
24
25#include "common/func.h"
26#include "twp/scenegraph.h"
27
28namespace Twp {
29
30#define asNone 0
31#define asOn 0x1
32#define asTemporaryUnselectable 0x2
33
34typedef void SelectFunc(int id);
35
36// This is where all the information about the actor icon stands
38 ActorSwitcherSlot(const Common::String &icon_, const Color &back_, const Color &frame_, SelectFunc *selectFunc_, int id_ = 0);
39
40 void select();
41
42 Common::String icon;
43 Color back, frame;
44 SelectFunc *selectFunc;
45 int id;
46};
47
48// This allows to change the selected actors or to display the options (gear icon)
49class ActorSwitcher : public Node {
50public:
52
53 void update(const Common::Array<ActorSwitcherSlot> &slots, float elapsed);
54 bool isMouseOver() const { return _mouseOver; }
55 void setFlash(int flash) { _flash = flash; }
56
57protected:
58 void drawCore(const Math::Matrix4 &trsf) override final;
59 void drawSprite(const SpriteSheetFrame &sf, Texture *texture, const Color &color, const Math::Matrix4 &trsf);
60 void drawIcon(const Common::String &icon, const Color &backColor, const Color &frameColor, const Math::Matrix4 &trsf, int index);
61 Math::Matrix4 transform(const Math::Matrix4 &trsf, int index);
62 float getAlpha(size_t index) const;
63 float height() const;
64 int iconIndex(const Math::Vector2d &pos) const;
65 Common::Rect rect() const;
66
67public:
68 int _mode = asNone; // current mode
69
70private:
71 bool _mouseOver = false; // true when mouse is over the icons
72 bool _down = false; // true when mouse button is down
73 float _alpha = 0.f; // alpha value for the icon when flash is ON (flash != 0)
74 int _flash = 0; // flash = 0: disable, flash = -1: enable, other values: time to flash
75 float _flashElapsed = 0.f; // flash time elapsed in seconds
76 float _animElapsed = 0.f, _animPos = 0.f; // animation time elapsed in seconds and current position in the animation [0f-1f]
77 Common::Array<ActorSwitcherSlot> _slots; // list of slots containing icon, colors and select function
78};
79
80} // namespace Twp
81
82#endif
Definition: array.h:52
Definition: str.h:59
Definition: actorswitcher.h:49
Definition: scenegraph.h:41
Definition: gfx.h:101
Definition: rect.h:536
Definition: actorswitcher.h:37
Definition: gfx.h:35
Definition: spritesheet.h:37