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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ZVISION_SLOT_CONTROL_H
24 #define ZVISION_SLOT_CONTROL_H
25 
26 #include "zvision/scripting/control.h"
27 
28 #include "graphics/surface.h"
29 
30 #include "common/rect.h"
31 #include "common/list.h"
32 
33 namespace ZVision {
34 
35 class SlotControl : public Control {
36 public:
37 	SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream);
38 	~SlotControl();
39 
40 	/**
41 	 * Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1);
42 	 *
43 	 * @param screenSpacePos             The position of the mouse in screen space
44 	 * @param backgroundImageSpacePos    The position of the mouse in background image space
45 	 */
46 	bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
47 	/**
48 	 * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor.
49 	 *
50 	 * @param engine                     The base engine
51 	 * @param screenSpacePos             The position of the mouse in screen space
52 	 * @param backgroundImageSpacePos    The position of the mouse in background image space
53 	 * @return                           Was the cursor changed?
54 	 */
55 	bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos);
56 
57 	bool process(uint32 deltaTimeInMillis);
58 
59 private:
60 	/**
61 	 * The area that will trigger the event
62 	 * This is in image space coordinates, NOT screen space
63 	 */
64 	Common::Rect _rectangle;
65 	Common::Rect _hotspot;
66 
67 	int _cursor;
68 	char _distanceId;
69 
70 	int _renderedItem;
71 
72 	Common::List<int> _eligibleObjects;
73 
74 	bool eligeblity(int itemId);
75 
76 	Graphics::Surface *_bkg;
77 
78 	/** The cursor to use when hovering over _hotspot */
79 	Common::String _hoverCursor;
80 };
81 
82 } // End of namespace ZVision
83 
84 #endif
85