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_CONTROL_H
24 #define ZVISION_CONTROL_H
25 
26 #include "common/keyboard.h"
27 #include "common/str.h"
28 
29 namespace Common {
30 class SeekableReadStream;
31 struct Point;
32 class WriteStream;
33 }
34 
35 namespace ZVision {
36 
37 class ZVision;
38 
39 /**
40  * The base class for all Controls.
41  *
42  * Controls are the things that the user interacts with. Ex: A lever on the door
43  */
44 class Control {
45 public:
46 
47 	enum ControlType {
48 		CONTROL_UNKNOW,
49 		CONTROL_INPUT,
50 		CONTROL_PUSHTGL,
51 		CONTROL_SLOT,
52 		CONTROL_LEVER,
53 		CONTROL_SAVE,
54 		CONTROL_SAFE,
55 		CONTROL_FIST,
56 		CONTROL_TITLER,
57 		CONTROL_HOTMOV,
58 		CONTROL_PAINT
59 	};
60 
Control(ZVision * engine,uint32 key,ControlType type)61 	Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type), _venusId(-1) {}
~Control()62 	virtual ~Control() {}
63 
getKey()64 	uint32 getKey() {
65 		return _key;
66 	}
67 
getType()68 	ControlType getType() {
69 		return _type;
70 	}
71 
focus()72 	virtual void focus() {}
unfocus()73 	virtual void unfocus() {}
74 	/**
75 	 * Called when LeftMouse is pushed. Default is NOP.
76 	 *
77 	 * @param screenSpacePos             The position of the mouse in screen space
78 	 * @param backgroundImageSpacePos    The position of the mouse in background image space
79 	 */
onMouseDown(const Common::Point & screenSpacePos,const Common::Point & backgroundImageSpacePos)80 	virtual bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
81 		return false;
82 	}
83 	/**
84 	 * Called when LeftMouse is lifted. Default is NOP.
85 	 *
86 	 * @param screenSpacePos             The position of the mouse in screen space
87 	 * @param backgroundImageSpacePos    The position of the mouse in background image space
88 	 */
onMouseUp(const Common::Point & screenSpacePos,const Common::Point & backgroundImageSpacePos)89 	virtual bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
90 		return false;
91 	}
92 	/**
93 	 * Called on every MouseMove. Default is NOP.
94 	 *
95 	 * @param screenSpacePos             The position of the mouse in screen space
96 	 * @param backgroundImageSpacePos    The position of the mouse in background image space
97 	 * @return                           Was the cursor changed?
98 	 */
onMouseMove(const Common::Point & screenSpacePos,const Common::Point & backgroundImageSpacePos)99 	virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {
100 		return false;
101 	}
102 	/**
103 	 * Called when a key is pressed. Default is NOP.
104 	 *
105 	 * @param keycode    The key that was pressed
106 	 */
onKeyDown(Common::KeyState keyState)107 	virtual bool onKeyDown(Common::KeyState keyState) {
108 		return false;
109 	}
110 	/**
111 	 * Called when a key is released. Default is NOP.
112 	 *
113 	 * @param keycode    The key that was pressed
114 	 */
onKeyUp(Common::KeyState keyState)115 	virtual bool onKeyUp(Common::KeyState keyState) {
116 		return false;
117 	}
118 	/**
119 	 * Processes the node given the deltaTime since last frame. Default is NOP.
120 	 *
121 	 * @param deltaTimeInMillis    The number of milliseconds that have passed since last frame
122 	 * @return                     If true, the node can be deleted after process() finishes
123 	 */
process(uint32 deltaTimeInMillis)124 	virtual bool process(uint32 deltaTimeInMillis) {
125 		return false;
126 	}
127 
128 	void setVenus();
129 
130 protected:
131 	ZVision *_engine;
132 	uint32 _key;
133 	int32 _venusId;
134 
135 	void getParams(const Common::String &inputStr, Common::String &parameter, Common::String &values);
136 // Static member functions
137 public:
138 	static void parseFlatControl(ZVision *engine);
139 	static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream);
140 	static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream);
141 private:
142 	ControlType _type;
143 };
144 
145 } // End of namespace ZVision
146 
147 #endif
148