ctrls.cpp ctrls.h OpenArena // //Module:ctrls.cpp //Author:TomHicks //Creation:09-01-2003 //LastEdit:06-19-2005 //Editors:TomHicks // //Purpose: //Toimplementasystemformanagingabindablecontrolscheme. // //SummaryofMethods: //ControlScheme //voidLoadDefaultControlScheme(); //-Loadsthedefaultcontrolscheme //voidClearControlScheme(); //-Clearsthecontrolscheme //voidUnbind(uint8key); //-Removeskeyfromallcontrollists. // //SummaryofProperties: //ControlScheme //-list<uint8>forward; //AlistoftheVKeysassociatedwithforward. //-list<uint8>backward; //AlistoftheVKeysassociatedwithbackward. //-list<uint8>lookLeft; //AlistoftheVKeysassociatedwithturningleft. //-list<uint8>lookRight; //AlistoftheVKeysassociatedwithturningright. //-list<uint8>lookUp; //AlistoftheVKeysassociatedwithlookingup. //-list<uint8>lookDown; //AlistoftheVKeysassociatedwithlookingdown. //-list<uint8>moveLeft; //AlistoftheVKeysassociatedwithstrafingleft. //-list<uint8>moveRight; //AlistoftheVKeysassociatedwithstrafingright. //-list<uint8>moveUp; //AlistoftheVKeysassociatedwithjumping. //-list<uint8>moveDown; //AlistoftheVKeysassociatedwithcrouching. //-list<uint8>firePrimary; //AlistoftheVKeysassociatedwithactivatingtheprimaryabilityoftheactiveitem. //-list<uint8>fireSecondary; //AlistoftheVKeysassociatedwithactivatingthesecondaryabliltyoftheactiveitem. //-list<uint8>weaponNext; //AlistoftheVKeysassociatedwithswitchingtothenextitem. //-list<uint8>weaponPrev; //AlistoftheVKeysassociatedwithswitchingtothepreviousitem. //-list<uint8>toggleLights; //AlistoftheVKeysassociatedwithturninglightingonandoff. //-list<uint8>toggleFPS; //AlistoftheVKeysassociatedwithturningtheFPSdisplayonandoff. //-list<uint8>toggleConsole; //AlistoftheVKeysassociatedwithtogglingthedisplayoftheconsole. //-list<uint8>toggleMouseLook; //AlistoftheVKeysassociatedwithtogglingmouselook. //-list<uint8>quickMouseLook; //AlistoftheVKeysassociatedwithtemporarilyswitchingthemouselookmode. //-list<uint8>rollLeft; //AlistoftheVKeysassociatedwithrollingleft. //-list<uint8>rollRight; //AlistoftheVKeysassociatedwithrollingright. // #include"ctrls.h" namespaceOpenArena{ voidControlScheme::LoadDefaultControlScheme() { forward.Insert(OpenArena::KEY_LBUTTON); backward.Insert(OpenArena::KEY_RBUTTON); lookLeft.Insert(OpenArena::KEY_LEFT); lookRight.Insert(OpenArena::KEY_RIGHT); lookUp.Insert(OpenArena::KEY_UP); lookDown.Insert(OpenArena::KEY_DOWN); moveLeft.Insert(OpenArena::KEY_S); moveRight.Insert(OpenArena::KEY_D); moveUp.Insert(OpenArena::KEY_SPACE); moveDown.Insert(OpenArena::KEY_A); firePrimary.Insert(OpenArena::KEY_F); fireSecondary.Insert(OpenArena::KEY_G); weaponNext.Insert(OpenArena::KEY_T); weaponPrev.Insert(OpenArena::KEY_R); toggleLights.Insert(OpenArena::KEY_L); toggleFPS.Insert(OpenArena::KEY_P); toggleConsole.Insert(OpenArena::KEY_OEM_3); toggleMouseLook.Insert(OpenArena::KEY_M); quickMouseLook.Insert(OpenArena::KEY_Q); rollLeft.Insert(OpenArena::KEY_W); rollRight.Insert(OpenArena::KEY_E); } voidControlScheme::ClearControlScheme() { backward.Clear(); firePrimary.Clear(); fireSecondary.Clear(); forward.Clear(); lookDown.Clear(); lookUp.Clear(); lookRight.Clear(); lookLeft.Clear(); moveDown.Clear(); moveUp.Clear(); moveLeft.Clear(); moveRight.Clear(); quickMouseLook.Clear(); toggleConsole.Clear(); toggleFPS.Clear(); toggleLights.Clear(); toggleMouseLook.Clear(); weaponNext.Clear(); weaponPrev.Clear(); } voidControlScheme::Unbind(uint8key) { backward.Remove(key); firePrimary.Remove(key); fireSecondary.Remove(key); forward.Remove(key); lookDown.Remove(key); lookUp.Remove(key); lookRight.Remove(key); lookLeft.Remove(key); moveDown.Remove(key); moveUp.Remove(key); moveRight.Remove(key); quickMouseLook.Remove(key); toggleConsole.Remove(key); toggleFPS.Remove(key); toggleLights.Remove(key); toggleMouseLook.Remove(key); weaponNext.Remove(key); weaponPrev.Remove(key); } boolControlScheme::Bind(uint32action,uint8key) { switch(action) { caseACTION_FORWARD: { Unbind(key); forward.Insert(key); returntrue; } caseACTION_BACKWARD: { Unbind(key); backward.Insert(key); returntrue; } caseACTION_LOOKLEFT: { Unbind(key); lookLeft.Insert(key); returntrue; } caseACTION_LOOKRIGHT: { Unbind(key); lookRight.Insert(key); returntrue; } caseACTION_LOOKUP: { Unbind(key); lookUp.Insert(key); returntrue; } caseACTION_LOOKDOWN: { Unbind(key); lookDown.Insert(key); returntrue; } caseACTION_MOVELEFT: { Unbind(key); moveLeft.Insert(key); returntrue; } caseACTION_MOVERIGHT: { Unbind(key); moveRight.Insert(key); returntrue; } caseACTION_MOVEUP: { Unbind(key); moveUp.Insert(key); returntrue; } caseACTION_MOVEDOWN: { Unbind(key); moveDown.Insert(key); returntrue; } caseACTION_ROLLLEFT: { Unbind(key); rollLeft.Insert(key); returntrue; } caseACTION_ROLLRIGHT: { Unbind(key); rollRight.Insert(key); returntrue; } caseACTION_FIREPRIMARY: { Unbind(key); firePrimary.Insert(key); returntrue; } caseACTION_FIRESECONDARY: { Unbind(key); fireSecondary.Insert(key); returntrue; } caseACTION_WEAPONNEXT: { Unbind(key); weaponNext.Insert(key); returntrue; } caseACTION_WEAPONPREV: { Unbind(key); weaponPrev.Insert(key); returntrue; } caseACTION_TOGGLE_LIGHTS: { Unbind(key); toggleLights.Insert(key); returntrue; } caseACTION_TOGGLE_FPS: { Unbind(key); toggleFPS.Insert(key); returntrue; } caseACTION_TOGGLE_CONSOLE: { Unbind(key); toggleConsole.Insert(key); returntrue; } caseACTION_TOGGLE_MOUSELOOK: { Unbind(key); toggleMouseLook.Insert(key); returntrue; } caseACTION_QUICKMOUSELOOK: { Unbind(key); quickMouseLook.Insert(key); returntrue; } default: returnfalse; } } };