Changes in client/Client/Textbox.cpp [87b3ee2:e607c0f] in network-game
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/Textbox.cpp
r87b3ee2 re607c0f 10 10 str = ""; 11 11 selected = false; 12 shiftPressed = false; 13 14 // populate the shift map 15 for(int i=0; i<26; i++) 16 shiftMap['a'+i] = 'A'+i; 17 18 shiftMap['1'] = '!'; 19 shiftMap['2'] = '@'; 20 shiftMap['3'] = '#'; 21 shiftMap['4'] = '$'; 22 shiftMap['5'] = '%'; 23 shiftMap['6'] = '^'; 24 shiftMap['7'] = '&'; 25 shiftMap['8'] = '*'; 26 shiftMap['9'] = '('; 27 shiftMap['0'] = ')'; 28 29 shiftMap['`'] = '~'; 30 shiftMap['-'] = '_'; 31 shiftMap['='] = '+'; 32 shiftMap['['] = '{'; 33 shiftMap[']'] = '}'; 34 shiftMap['\\'] = '|'; 35 shiftMap[';'] = ':'; 36 shiftMap['\''] = '\"'; 37 shiftMap[','] = '<'; 38 shiftMap['.'] = '>'; 39 shiftMap['/'] = '?'; 40 shiftMap[' '] = ' '; 12 41 } 13 42 … … 70 99 char newChar = 0; 71 100 72 if (ALLEGRO_KEY_A <= e.keyboard.keycode && e.keyboard.keycode <= ALLEGRO_KEY_Z) {101 if (ALLEGRO_KEY_A <= e.keyboard.keycode && e.keyboard.keycode <= ALLEGRO_KEY_Z) 73 102 newChar = 'a'+e.keyboard.keycode-ALLEGRO_KEY_A; 74 if (al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT))75 newChar -= 32;76 }77 103 else if (ALLEGRO_KEY_0 <= e.keyboard.keycode && e.keyboard.keycode <= ALLEGRO_KEY_9) 78 104 newChar = '0'+e.keyboard.keycode-ALLEGRO_KEY_0; 79 else if (e.keyboard.keycode = ALLEGRO_KEY_BACKSPACE && str.size() > 0) 80 str = str.substr(0, str.size()-1); 105 else { 106 switch(e.keyboard.keycode) 107 { 108 case ALLEGRO_KEY_TILDE: 109 newChar = '`'; 110 break; 111 case ALLEGRO_KEY_MINUS: 112 newChar = '-'; 113 break; 114 case ALLEGRO_KEY_EQUALS: 115 newChar = '='; 116 break; 117 case ALLEGRO_KEY_OPENBRACE: 118 newChar = '['; 119 break; 120 case ALLEGRO_KEY_CLOSEBRACE: 121 newChar = ']'; 122 break; 123 case ALLEGRO_KEY_SEMICOLON: 124 newChar = ';'; 125 break; 126 case ALLEGRO_KEY_QUOTE: 127 newChar = '\''; 128 break; 129 case ALLEGRO_KEY_BACKSLASH: 130 newChar = '\\'; 131 break; 132 case ALLEGRO_KEY_COMMA: 133 newChar = ','; 134 break; 135 case ALLEGRO_KEY_FULLSTOP: 136 newChar = '.'; 137 break; 138 case ALLEGRO_KEY_SLASH: 139 newChar = '/'; 140 break; 141 case ALLEGRO_KEY_SPACE: 142 newChar = ' '; 143 break; 144 case ALLEGRO_KEY_BACKSPACE: 145 if (str.size() > 0) 146 { 147 str = str.substr(0, str.size()-1); 148 return true; 149 } 150 else 151 return false; 152 break; 153 case ALLEGRO_KEY_LSHIFT: 154 case ALLEGRO_KEY_RSHIFT: 155 shiftPressed = true; 156 break; 157 default: 158 cout << "unknown keycode: " << e.keyboard.keycode << endl; 159 break; 160 } 161 } 81 162 82 163 if (newChar != 0) { 164 if (al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT)) 165 newChar = shiftMap[newChar]; 166 83 167 str.append(1, newChar); 84 168 return true; 169 } 170 } 171 else if (e.type == ALLEGRO_EVENT_KEY_UP) { 172 switch(e.keyboard.keycode) 173 { 174 case ALLEGRO_KEY_LSHIFT: 175 case ALLEGRO_KEY_RSHIFT: 176 shiftPressed = false; 177 break; 85 178 } 86 179 }
Note:
See TracChangeset
for help on using the changeset viewer.