aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/input.h
blob: e26f4d71fd49c2ad232317cc49a6517e7e1d5773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 *
 */

#ifndef PARALLACTION_INPUT_H
#define PARALLACTION_INPUT_H

#include "common/keyboard.h"

#include "parallaction/objects.h"
#include "parallaction/inventory.h"

namespace Parallaction {

enum {
	kMouseNone			= 0,
	kMouseLeftUp		= 1,
	kMouseLeftDown		= 2,
	kMouseRightUp		= 4,
	kMouseRightDown		= 8
};

enum MouseTriState {
	MOUSE_ENABLED_SHOW,
	MOUSE_ENABLED_HIDE,
	MOUSE_DISABLED
};

class Input {
	int 		updateGameInput();

	bool		_hasKeyPressEvent;
	Common::KeyState _keyPressed;

	bool		_hasDelayedAction;  // actived when the character needs to move before taking an action
	ZonePtr		_delayedActionZone;

	int16		_transCurrentHoverItem;

	void		translateInput();
	bool		translateGameInput();
	bool		updateInventoryInput();
	void 		takeAction(ZonePtr z);
	void 		walkTo(const Common::Point &dest);

	Parallaction	*_vm;

	Common::Point	_mousePos;
	uint16	_mouseButtons;

	ZonePtr			_hoverZone;

	void	enterInventoryMode();
	void 	exitInventoryMode();

	int		_gameType;

	static byte _resMouseArrow_NS[256];
	Frames	*_mouseArrow;
	Frames	*_comboArrow;
	Frames	*_dinoCursor;
	Frames	*_dougCursor;
	Frames	*_donnaCursor;

	void initCursors();

public:
	enum {
		kInputModeGame = 0,
		kInputModeComment = 1,
		kInputModeDialogue = 2,
		kInputModeInventory = 3,
		kInputModeMenu = 4
	};


	Input(Parallaction *vm);
	virtual ~Input();

	void getAbsoluteCursorPos(Common::Point& p) const;

	void getCursorPos(Common::Point& p) const {
		p = _mousePos;
	}

	void setCursorPos(const Common::Point& p) {
		_mousePos = p;
	}

	int				_inputMode;
	InventoryItem	_activeItem;

	void	readInput();
	int 	updateInput();
	void	trackMouse(ZonePtr z);
	void	waitForButtonEvent(uint32 buttonEventMask, int32 timeout = -1);
	uint32	getLastButtonEvent() { return _mouseButtons; }
	bool  	getLastKeyDown(uint16 &ascii);

	void stopHovering();

	MouseTriState _mouseState;

	void setMouseState(MouseTriState state);
	MouseTriState getMouseState();
	bool isMouseEnabled();

	void setArrowCursor();
	void setInventoryCursor(ItemName name);
};

} // namespace Parallaction

#endif