ScummVM API documentation
event.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 SLUDGE_EVENT_H
23 #define SLUDGE_EVENT_H
24 
25 namespace Common {
26 class SeekableReadStream;
27 class WriteStream;
28 }
29 
30 namespace Sludge {
31 
32 struct FrozenStuffStruct;
33 
34 struct InputType {
35  bool leftClick, rightClick, justMoved, leftRelease, rightRelease;
36  int mouseX, mouseY, keyPressed;
37 };
38 
39 enum EventFunctions {
40  kLeftMouse,
41  kLeftMouseUp,
42  kRightMouse,
43  kRightMouseUp,
44  kMoveMouse,
45  kFocus,
46  kSpace,
47  EVENT_FUNC_NB
48 };
49 
50 struct EventHandlers {
51  int func[EVENT_FUNC_NB];
52 };
53 
54 class SludgeEngine;
55 
56 class EventManager {
57 public:
59  virtual ~EventManager();
60 
61  void init();
62  void kill();
63 
64  // Input
65  void checkInput();
66  bool handleInput();
67 
68  int mouseX() const { return _input.mouseX; }
69  int mouseY() const { return _input.mouseY; }
70  int &mouseX() { return _input.mouseX; }
71  int &mouseY() { return _input.mouseY; }
72 
73  // Events
74  void setEventFunction(EventFunctions event, int funcNum) { _currentEvents->func[event] = funcNum; };
75  void loadHandlers(Common::SeekableReadStream *stream);
76  void saveHandlers(Common::WriteStream *stream);
77  bool freeze(FrozenStuffStruct *frozenStuff);
78  void restore(FrozenStuffStruct *frozenStuff);
79 
80  // Quit
81  void startGame() { _weAreDoneSoQuit = false; }
82  void quitGame() { _weAreDoneSoQuit = true; /* _reallyWantToQuit = true; */ }
83  bool quit() { return _weAreDoneSoQuit; }
84 
85 private:
86  SludgeEngine *_vm;
87  InputType _input;
88 
89  int _weAreDoneSoQuit;
90  bool _reallyWantToQuit;
91 
92  EventHandlers *_currentEvents;
93 };
94 
95 } /* namespace Sludge */
96 
97 #endif /* ENGINES_SLUDGE_EVENT_H_ */
Definition: stream.h:77
Definition: stream.h:745
Definition: sludge.h:68
Definition: event.h:56
Definition: builtin.h:27
Definition: algorithm.h:29
Definition: freeze.h:41
Definition: event.h:50
Definition: event.h:34