Planeshift
psmousebinds.h
Go to the documentation of this file.
1 /*
2  * psmousebinds.h - Author: Andrew Robberts
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
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 (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PAWS_MOUSE_BINDS_HEADER
21 #define PAWS_MOUSE_BINDS_HEADER
22 
23 #include <csutil/ref.h>
24 #include <csutil/list.h>
25 #include <csutil/parray.h>
26 #include <csutil/array.h>
27 #include <iutil/event.h>
28 #include <csutil/parray.h>
29 
30 #include <iutil/vfs.h>
31 #include <iutil/document.h>
32 
33 struct iObjectRegistry;
34 struct iEvent;
35 
40 // structure to hold each action and mouse actions that is associated with it
42 {
43  csString action;
44  csMouseEventData event;
45 };
46 
47 // structure to hold boolean mouse settings
49 {
50  csString option;
51  bool value;
52 };
53 
54 // structure to hold integer mouse settings
55 struct psMouseInt
56 {
57  csString option;
58  int value;
59 };
60 
65 {
66 public:
68 
76  bool LoadFromFile(iObjectRegistry* object_reg, const csString &filename);
77 
78 
86  bool SaveToFile(iObjectRegistry* object_reg, const csString &filename);
87 
88 
95  void Bind(const csString &action, csMouseEventData &event);
96 
97  void Bind(const csString &action, csString &event, csString &ctrl);
98  void Bind(const csString &action, int button, int modifier);
99 
100 
107  void SetOnOff(const csString &option, csString &value);
108  void SetOnOff(const csString &option, bool value);
109 
110 
117  void SetInt(const csString &option, csString &value);
118  void SetInt(const csString &option, int value);
119 
120 
128  bool GetBind(const csString &action, csMouseEventData &event);
129  bool GetBind(const csString &action, csString &button);
130 
139  bool CheckBind(const csString &action, int button, int modifiers);
140 
148  bool GetOnOff(const csString &option, csString &value);
149  bool GetOnOff(const csString &option, bool &value);
150 
151 
159  bool GetInt(const csString &option, csString &value);
160  bool GetInt(const csString &option, int &value);
161 
162 
168  void Unbind(const csString &action);
169 
170 
176  void RemoveOnOff(const csString &option);
177 
178 
184  void RemoveInt(const csString &option);
185 
186 
191  void UnbindAll();
192 
193  static csString MouseButtonToString(uint button, uint32 modifiers);
194  static bool StringToMouseButton(const csString &str, uint &button, uint32 &modifiers);
195 
196 protected:
197 
204  psMouseBind* FindAction(const csString &action);
205 
206 
213  psMouseOnOff* FindOnOff(const csString &option);
214 
215 
222  psMouseInt* FindInt(const csString &option);
223 
225  csPDelArray<psMouseBind> binds;
226  csPDelArray<psMouseOnOff> boolOptions;
227  csPDelArray<psMouseInt> intOptions;
228 };
229 
232 #endif
233 
234 
csPDelArray< psMouseInt > intOptions
Definition: psmousebinds.h:227
csMouseEventData event
Definition: psmousebinds.h:44
csString option
Definition: psmousebinds.h:50
psMouseBinds holds set of psMouseAction
Definition: psmousebinds.h:64
csPDelArray< psMouseOnOff > boolOptions
Definition: psmousebinds.h:226
csString option
Definition: psmousebinds.h:57
csPDelArray< psMouseBind > binds
list of the binds
Definition: psmousebinds.h:225
csString action
Definition: psmousebinds.h:43