#include <Typer.h>
Public Methods | |
| Typer () | |
| Typer (string initialString) | |
| string | getString () |
| void | input () |
| void | clear () |
Protected Methods | |
| void | delLastChar () |
Protected Attributes | |
| DWORD | m_lastDelMilliSec |
| string | m_string |
| vector< Int3Tuple > | typerCharSet |
|
|
Definition at line 26 of file Typer.cpp.
00027 {
00028 *this = Typer("");
00029 }
|
|
|
Definition at line 31 of file Typer.cpp. References m_string, and typerCharSet.
00032 {
00033 if( typerCharSet.size()==0 ) // init charSet once
00034 {
00035 typerCharSet.push_back( Int3Tuple( KeyCodes::key_A, 1, (int)'A' ) );
00036 typerCharSet.push_back( Int3Tuple( KeyCodes::key_B, 1, (int)'B' ) );
00037 typerCharSet.push_back( Int3Tuple( KeyCodes::key_C, 1, (int)'C' ) );
00038 typerCharSet.push_back( Int3Tuple( KeyCodes::key_D, 1, (int)'D' ) );
00039 typerCharSet.push_back( Int3Tuple( KeyCodes::key_E, 1, (int)'E' ) );
00040 typerCharSet.push_back( Int3Tuple( KeyCodes::key_F, 1, (int)'F' ) );
00041 typerCharSet.push_back( Int3Tuple( KeyCodes::key_G, 1, (int)'G' ) );
00042 typerCharSet.push_back( Int3Tuple( KeyCodes::key_H, 1, (int)'H' ) );
00043 typerCharSet.push_back( Int3Tuple( KeyCodes::key_I, 1, (int)'I' ) );
00044 typerCharSet.push_back( Int3Tuple( KeyCodes::key_J, 1, (int)'J' ) );
00045 typerCharSet.push_back( Int3Tuple( KeyCodes::key_K, 1, (int)'K' ) );
00046 typerCharSet.push_back( Int3Tuple( KeyCodes::key_L, 1, (int)'L' ) );
00047 typerCharSet.push_back( Int3Tuple( KeyCodes::key_M, 1, (int)'M' ) );
00048 typerCharSet.push_back( Int3Tuple( KeyCodes::key_N, 1, (int)'N' ) );
00049 typerCharSet.push_back( Int3Tuple( KeyCodes::key_O, 1, (int)'O' ) );
00050 typerCharSet.push_back( Int3Tuple( KeyCodes::key_P, 1, (int)'P' ) );
00051 typerCharSet.push_back( Int3Tuple( KeyCodes::key_Q, 1, (int)'Q' ) );
00052 typerCharSet.push_back( Int3Tuple( KeyCodes::key_R, 1, (int)'R' ) );
00053 typerCharSet.push_back( Int3Tuple( KeyCodes::key_S, 1, (int)'S' ) );
00054 typerCharSet.push_back( Int3Tuple( KeyCodes::key_T, 1, (int)'T' ) );
00055 typerCharSet.push_back( Int3Tuple( KeyCodes::key_U, 1, (int)'U' ) );
00056 typerCharSet.push_back( Int3Tuple( KeyCodes::key_V, 1, (int)'V' ) );
00057 typerCharSet.push_back( Int3Tuple( KeyCodes::key_W, 1, (int)'W' ) );
00058 typerCharSet.push_back( Int3Tuple( KeyCodes::key_X, 1, (int)'X' ) );
00059 typerCharSet.push_back( Int3Tuple( KeyCodes::key_Y, 1, (int)'Y' ) );
00060 typerCharSet.push_back( Int3Tuple( KeyCodes::key_Z, 1, (int)'Z' ) );
00061 typerCharSet.push_back( Int3Tuple( KeyCodes::key_A, 0, (int)'a' ) );
00062 typerCharSet.push_back( Int3Tuple( KeyCodes::key_B, 0, (int)'b' ) );
00063 typerCharSet.push_back( Int3Tuple( KeyCodes::key_C, 0, (int)'c' ) );
00064 typerCharSet.push_back( Int3Tuple( KeyCodes::key_D, 0, (int)'d' ) );
00065 typerCharSet.push_back( Int3Tuple( KeyCodes::key_E, 0, (int)'e' ) );
00066 typerCharSet.push_back( Int3Tuple( KeyCodes::key_F, 0, (int)'f' ) );
00067 typerCharSet.push_back( Int3Tuple( KeyCodes::key_G, 0, (int)'g' ) );
00068 typerCharSet.push_back( Int3Tuple( KeyCodes::key_H, 0, (int)'h' ) );
00069 typerCharSet.push_back( Int3Tuple( KeyCodes::key_I, 0, (int)'i' ) );
00070 typerCharSet.push_back( Int3Tuple( KeyCodes::key_J, 0, (int)'j' ) );
00071 typerCharSet.push_back( Int3Tuple( KeyCodes::key_K, 0, (int)'k' ) );
00072 typerCharSet.push_back( Int3Tuple( KeyCodes::key_L, 0, (int)'l' ) );
00073 typerCharSet.push_back( Int3Tuple( KeyCodes::key_M, 0, (int)'m' ) );
00074 typerCharSet.push_back( Int3Tuple( KeyCodes::key_N, 0, (int)'n' ) );
00075 typerCharSet.push_back( Int3Tuple( KeyCodes::key_O, 0, (int)'o' ) );
00076 typerCharSet.push_back( Int3Tuple( KeyCodes::key_P, 0, (int)'p' ) );
00077 typerCharSet.push_back( Int3Tuple( KeyCodes::key_Q, 0, (int)'q' ) );
00078 typerCharSet.push_back( Int3Tuple( KeyCodes::key_R, 0, (int)'r' ) );
00079 typerCharSet.push_back( Int3Tuple( KeyCodes::key_S, 0, (int)'s' ) );
00080 typerCharSet.push_back( Int3Tuple( KeyCodes::key_T, 0, (int)'t' ) );
00081 typerCharSet.push_back( Int3Tuple( KeyCodes::key_U, 0, (int)'u' ) );
00082 typerCharSet.push_back( Int3Tuple( KeyCodes::key_V, 0, (int)'v' ) );
00083 typerCharSet.push_back( Int3Tuple( KeyCodes::key_W, 0, (int)'w' ) );
00084 typerCharSet.push_back( Int3Tuple( KeyCodes::key_X, 0, (int)'x' ) );
00085 typerCharSet.push_back( Int3Tuple( KeyCodes::key_Y, 0, (int)'y' ) );
00086 typerCharSet.push_back( Int3Tuple( KeyCodes::key_Z, 0, (int)'z' ) );
00087 typerCharSet.push_back( Int3Tuple( KeyCodes::key_0, 1, (int)')' ) );
00088 typerCharSet.push_back( Int3Tuple( KeyCodes::key_1, 1, (int)'!' ) );
00089 typerCharSet.push_back( Int3Tuple( KeyCodes::key_2, 1, (int)'@' ) );
00090 typerCharSet.push_back( Int3Tuple( KeyCodes::key_3, 1, (int)'#' ) );
00091 typerCharSet.push_back( Int3Tuple( KeyCodes::key_4, 1, (int)'$' ) );
00092 typerCharSet.push_back( Int3Tuple( KeyCodes::key_5, 1, (int)'%' ) );
00093 typerCharSet.push_back( Int3Tuple( KeyCodes::key_6, 1, (int)'^' ) );
00094 typerCharSet.push_back( Int3Tuple( KeyCodes::key_7, 1, (int)'&' ) );
00095 typerCharSet.push_back( Int3Tuple( KeyCodes::key_8, 1, (int)'*' ) );
00096 typerCharSet.push_back( Int3Tuple( KeyCodes::key_9, 1, (int)'(' ) );
00097 typerCharSet.push_back( Int3Tuple( KeyCodes::key_0, 0, (int)'0' ) );
00098 typerCharSet.push_back( Int3Tuple( KeyCodes::key_1, 0, (int)'1' ) );
00099 typerCharSet.push_back( Int3Tuple( KeyCodes::key_2, 0, (int)'2' ) );
00100 typerCharSet.push_back( Int3Tuple( KeyCodes::key_3, 0, (int)'3' ) );
00101 typerCharSet.push_back( Int3Tuple( KeyCodes::key_4, 0, (int)'4' ) );
00102 typerCharSet.push_back( Int3Tuple( KeyCodes::key_5, 0, (int)'5' ) );
00103 typerCharSet.push_back( Int3Tuple( KeyCodes::key_6, 0, (int)'6' ) );
00104 typerCharSet.push_back( Int3Tuple( KeyCodes::key_7, 0, (int)'7' ) );
00105 typerCharSet.push_back( Int3Tuple( KeyCodes::key_8, 0, (int)'8' ) );
00106 typerCharSet.push_back( Int3Tuple( KeyCodes::key_9, 0, (int)'9' ) );
00107 typerCharSet.push_back( Int3Tuple( KeyCodes::key_SPACE, 0, (int)' ' ) );
00108 typerCharSet.push_back( Int3Tuple( KeyCodes::key_SPACE, 1, (int)' ' ) );
00109 typerCharSet.push_back( Int3Tuple( KeyCodes::key_COMMA, 1, (int)'<' ) );
00110 typerCharSet.push_back( Int3Tuple( KeyCodes::key_PERIOD, 1, (int)'>' ) );
00111 typerCharSet.push_back( Int3Tuple( KeyCodes::key_COMMA, 0, (int)',' ) );
00112 typerCharSet.push_back( Int3Tuple( KeyCodes::key_PERIOD, 0, (int)'.' ) );
00113 typerCharSet.push_back( Int3Tuple( KeyCodes::key_SEMICOLON, 1, (int)':' ) );
00114 typerCharSet.push_back( Int3Tuple( KeyCodes::key_SEMICOLON, 0, (int)';' ) );
00115 typerCharSet.push_back( Int3Tuple( KeyCodes::key_MINUS, 1, (int)'_' ) );
00116 typerCharSet.push_back( Int3Tuple( KeyCodes::key_MINUS, 0, (int)'-' ) );
00117 typerCharSet.push_back( Int3Tuple( KeyCodes::key_EQUALS, 1, (int)'+' ) );
00118 typerCharSet.push_back( Int3Tuple( KeyCodes::key_EQUALS, 0, (int)'-' ) );
00119 typerCharSet.push_back( Int3Tuple( KeyCodes::key_APOSTROPHE, 1, (int)'"' ) );
00120 typerCharSet.push_back( Int3Tuple( KeyCodes::key_APOSTROPHE, 0, (int)'\'' ) );
00121 typerCharSet.push_back( Int3Tuple( KeyCodes::key_SLASH, 1, (int)'?' ) );
00122 typerCharSet.push_back( Int3Tuple( KeyCodes::key_SLASH, 0, (int)'/' ) );
00123 typerCharSet.push_back( Int3Tuple( KeyCodes::key_BACKSLASH, 1, (int)'|' ) );
00124 typerCharSet.push_back( Int3Tuple( KeyCodes::key_BACKSLASH, 0, (int)'\\' ) );
00125 typerCharSet.push_back( Int3Tuple( KeyCodes::key_LBRACKET, 1, (int)'{' ) );
00126 typerCharSet.push_back( Int3Tuple( KeyCodes::key_LBRACKET, 0, (int)'[' ) );
00127 typerCharSet.push_back( Int3Tuple( KeyCodes::key_RBRACKET, 1, (int)'}' ) );
00128 typerCharSet.push_back( Int3Tuple( KeyCodes::key_RBRACKET, 0, (int)']' ) );
00129 typerCharSet.push_back( Int3Tuple( 41, 1, (int)'~' ) ); // special keys : ~ , `
00130 typerCharSet.push_back( Int3Tuple( 41, 0, (int)'`' ) ); //
00131 }
00132
00133 m_string = initialString;
00134 }
|
|
|
Definition at line 176 of file Typer.cpp. References m_string. Referenced by Overhead::overhead_update().
00177 {
00178 m_string.clear();
00179 }
|
|
|
Definition at line 141 of file Typer.cpp. References m_string. Referenced by input().
|
|
|
Definition at line 136 of file Typer.cpp. References m_string. Referenced by Overhead::overhead_render(), Overhead::overhead_update(), renderMultiplayMenu(), and updateMultiplayMenu().
00137 {
00138 return m_string;
00139 }
|
|
|
Definition at line 147 of file Typer.cpp. References delLastChar(), input_isKeyDown(), input_isKeyPressed(), m_lastDelMilliSec, m_string, sys_getMilliSec(), and typerCharSet. Referenced by Overhead::overhead_update(), and updateMultiplayMenu().
00148 {
00149 assert(typerCharSet.size() > 0);
00150 int shift = 0;
00151 if (input_isKeyDown(KeyCodes::key_LSHIFT) || input_isKeyDown(KeyCodes::key_RSHIFT))
00152 shift = 1;
00153
00154 for( int i=0; i<(int)typerCharSet.size(); i++ )
00155 if( typerCharSet[i].b == shift )
00156 {
00157 int k = typerCharSet[i].a; // keycode to check
00158 if( input_isKeyPressed(k) )
00159 m_string += (char) typerCharSet[i].c;
00160 }
00161
00162 // deleting using BackSpace
00163 if( input_isKeyPressed(KeyCodes::key_BACK) )
00164 {
00165 delLastChar();
00166 m_lastDelMilliSec = sys_getMilliSec() + 400;
00167 }
00168
00169 if( input_isKeyDown(KeyCodes::key_BACK) && sys_getMilliSec() >= 90 + m_lastDelMilliSec )
00170 {
00171 delLastChar();
00172 m_lastDelMilliSec = sys_getMilliSec();
00173 }
00174 }
|
|
|
Definition at line 47 of file Typer.h. Referenced by input(). |
|
|
Definition at line 48 of file Typer.h. Referenced by clear(), delLastChar(), getString(), input(), and Typer(). |
|
|
|
1.3-rc2