Planeshift
|
00001 /* 00002 * psmousebinds.h - Author: Andrew Robberts 00003 * 00004 * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 00020 #ifndef PAWS_MOUSE_BINDS_HEADER 00021 #define PAWS_MOUSE_BINDS_HEADER 00022 00023 #include <csutil/ref.h> 00024 #include <csutil/list.h> 00025 #include <csutil/parray.h> 00026 #include <csutil/array.h> 00027 #include <iutil/event.h> 00028 #include <csutil/parray.h> 00029 00030 #include <iutil/vfs.h> 00031 #include <iutil/document.h> 00032 00033 struct iObjectRegistry; 00034 struct iEvent; 00035 00040 // structure to hold each action and mouse actions that is associated with it 00041 struct psMouseBind 00042 { 00043 csString action; 00044 csMouseEventData event; 00045 }; 00046 00047 // structure to hold boolean mouse settings 00048 struct psMouseOnOff 00049 { 00050 csString option; 00051 bool value; 00052 }; 00053 00054 // structure to hold integer mouse settings 00055 struct psMouseInt 00056 { 00057 csString option; 00058 int value; 00059 }; 00060 00064 class psMouseBinds 00065 { 00066 public: 00067 psMouseBinds() {} 00068 00076 bool LoadFromFile(iObjectRegistry* object_reg, const csString &filename); 00077 00078 00086 bool SaveToFile(iObjectRegistry* object_reg, const csString &filename); 00087 00088 00095 void Bind(const csString &action, csMouseEventData &event); 00096 00097 void Bind(const csString &action, csString &event, csString &ctrl); 00098 void Bind(const csString &action, int button, int modifier); 00099 00100 00107 void SetOnOff(const csString &option, csString &value); 00108 void SetOnOff(const csString &option, bool value); 00109 00110 00117 void SetInt(const csString &option, csString &value); 00118 void SetInt(const csString &option, int value); 00119 00120 00128 bool GetBind(const csString &action, csMouseEventData &event); 00129 bool GetBind(const csString &action, csString &button); 00130 00139 bool CheckBind(const csString &action, int button, int modifiers); 00140 00148 bool GetOnOff(const csString &option, csString &value); 00149 bool GetOnOff(const csString &option, bool &value); 00150 00151 00159 bool GetInt(const csString &option, csString &value); 00160 bool GetInt(const csString &option, int &value); 00161 00162 00168 void Unbind(const csString &action); 00169 00170 00176 void RemoveOnOff(const csString &option); 00177 00178 00184 void RemoveInt(const csString &option); 00185 00186 00191 void UnbindAll(); 00192 00193 static csString MouseButtonToString(uint button, uint32 modifiers); 00194 static bool StringToMouseButton(const csString &str, uint &button, uint32 &modifiers); 00195 00196 protected: 00197 00204 psMouseBind* FindAction(const csString &action); 00205 00206 00213 psMouseOnOff* FindOnOff(const csString &option); 00214 00215 00222 psMouseInt* FindInt(const csString &option); 00223 00225 csPDelArray<psMouseBind> binds; 00226 csPDelArray<psMouseOnOff> boolOptions; 00227 csPDelArray<psMouseInt> intOptions; 00228 }; 00229 00232 #endif 00233 00234