00001
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #pragma once
00033
00034
00035 #include <iostream>
00036 #include <map>
00037 #include <string>
00038 using namespace std;
00039 #include "K3dKeyMap.h"
00040 #include "../System/K3dString.h"
00041 #include "../System/K3dDefines.h"
00042 #include "../System/GameData/K3dGameData.h"
00043 #include "../System/K3dTypedef.h"
00044 #include "../Script/K3dLua.h"
00045
00046
00047
00048
00049 typedef std::map<std::string, EKeyMapAction> TStrActionMap;
00050 typedef std::pair<std::string, EKeyMapAction> TStrActionPair;
00051
00052
00053
00054 class K3dKeyMapBuild
00055 {
00056 K3dGameData *m_pGameData;
00057 TStrActionMap m_tActionTransferMap;
00058 TStrIntMap m_tKeyTransferMap;
00059 bool m_bIsKeyMapLoaded;
00060
00064 void CheckLoadError ( std::string _strLoad, K3dString _strFind )
00065 {
00066 if ( _strLoad=="" )
00067 {
00068 cerr << "Error in void K3dKeyMapBuild::LoadKeyMap() -- Error - Load value " +_strFind.GetString() + " is not exist." << endl;
00069 }
00070 }
00071
00072 void GenerateKeyMap ( std::string _strKeyMap, std::string _strActionMap );
00073 public:
00074 K3dKeyMapBuild ( K3dGameData *_pGameData )
00075 {
00076
00077 m_pGameData = _pGameData;
00078
00079 m_bIsKeyMapLoaded = false;
00080
00081
00082 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_GO_FORWARD, K_GO_FORWARD ) );
00083 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_GO_BACKWARD,K_GO_BACKWARD ) );
00084 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_GO_UP,K_GO_UP ) );
00085 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_GO_DOWN, K_GO_DOWN ) );
00086 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_STRAFE_LEFT,K_STRAFE_LEFT ) );
00087 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_STRAFE_RIGHT,K_STRAFE_RIGHT ) );
00088 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_LURCH_LEFT,K_LURCH_LEFT ) );
00089 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_LURCH_RIGHT,K_LURCH_RIGHT ) );
00090 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_TURN_LEFT,K_TURN_LEFT ) );
00091 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_TURN_RIGHT,K_TURN_RIGHT ) );
00092 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_TURN_UP,K_TURN_UP ) );
00093 m_tActionTransferMap.insert ( TStrActionPair ( K_STR_TURN_DOWN,K_TURN_DOWN ) );
00094
00095
00096 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_ESC,SDLK_ESCAPE ) );
00097 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_A,SDLK_a ) );
00098 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_B,SDLK_b ) );
00099 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_C,SDLK_c ) );
00100 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_D,SDLK_d ) );
00101 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_E,SDLK_e ) );
00102 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F,SDLK_f ) );
00103 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_G,SDLK_g ) );
00104 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_H,SDLK_h ) );
00105 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_I,SDLK_i ) );
00106 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_J,SDLK_j ) );
00107 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_K,SDLK_k ) );
00108 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_L,SDLK_l ) );
00109 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_M,SDLK_m ) );
00110 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_N,SDLK_n ) );
00111 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_O,SDLK_o ) );
00112 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_P,SDLK_p ) );
00113 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_Q,SDLK_q ) );
00114 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_R,SDLK_r ) );
00115 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_S,SDLK_s ) );
00116 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_T,SDLK_t ) );
00117 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_U,SDLK_u ) );
00118 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_V,SDLK_v ) );
00119 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_W,SDLK_w ) );
00120 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_X,SDLK_x ) );
00121 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_Y,SDLK_y ) );
00122 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_Z,SDLK_z ) );
00123 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F1,SDLK_F1 ) );
00124 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F2,SDLK_F2 ) );
00125 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F3,SDLK_F3 ) );
00126 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F4,SDLK_F4 ) );
00127 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F5,SDLK_F5 ) );
00128 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F6,SDLK_F6 ) );
00129 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F7,SDLK_F7 ) );
00130 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F8,SDLK_F8 ) );
00131 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F9,SDLK_F9 ) );
00132 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F10,SDLK_F10 ) );
00133 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F11,SDLK_F11 ) );
00134 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_F12,SDLK_F12 ) );
00135 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_LEFT,SDLK_LEFT ) );
00136 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_RIGHT,SDLK_RIGHT ) );
00137 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_UP,SDLK_UP ) );
00138 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_DOWN,SDLK_DOWN ) );
00139 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_PAGE_DOWN,SDLK_PAGEDOWN ) );
00140 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_PAGE_UP,SDLK_PAGEUP ) );
00141 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_HOME, SDLK_HOME ) );
00142 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_END, SDLK_END ) );
00143 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_INSERT, SDLK_INSERT ) );
00144 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_DELETE, SDLK_DELETE ) );
00145 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_CONSOLE, SDLK_BACKQUOTE ) );
00146 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_ZERO, SDLK_KP0 ) );
00147 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_1, SDLK_KP1 ) );
00148 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_2, SDLK_KP2 ) );
00149 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_3, SDLK_KP3 ) );
00150 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_4, SDLK_KP4 ) );
00151 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_5, SDLK_KP5 ) );
00152 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_6, SDLK_KP6 ) );
00153 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_7, SDLK_KP7 ) );
00154 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_8, SDLK_KP8 ) );
00155 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_9, SDLK_KP9 ) );
00156 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_PLUS, SDLK_PLUS ) );
00157 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_MINUS, SDLK_MINUS ) );
00158 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_BACKSPACE, SDLK_BACKSPACE ) );
00159 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_SPACE, SDLK_SPACE ) );
00160 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_ENTER, SDLK_KP_ENTER ) );
00161 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_LSHIFT, SDLK_LSHIFT ) );
00162 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_RSHIFT, SDLK_RSHIFT ) );
00163 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_LCTRL, SDLK_LCTRL ) );
00164 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_RCTRL, SDLK_RCTRL ) );
00165 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_LALT, SDLK_LALT ) );
00166 m_tKeyTransferMap.insert ( TStrIntPair ( K_STR_RALT, SDLK_RALT ) );
00167 }
00168 ~K3dKeyMapBuild()
00169 {
00170
00171 m_tActionTransferMap.clear();
00172 m_tKeyTransferMap.clear();
00173 }
00174
00175 void LoadKeyMap();
00176 };
00177
00178
00179