Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Console
- {
- public:
- typedef std::list<String> InputList;
- enum Result
- {
- NOTHING = 0,
- ENTERED,
- ESCAPED
- };
- static const String& GetInput() { return input; }
- static Result Query(SDLKey lastKey)
- {
- if(lastResult == ENTERED || lastResult == ESCAPED)
- {
- input.clear();
- }
- switch (lastKey)
- {
- case SDLK_a:
- case SDLK_b:
- case SDLK_c:
- case SDLK_d:
- case SDLK_e:
- case SDLK_f:
- case SDLK_g:
- case SDLK_h:
- case SDLK_i:
- case SDLK_j:
- case SDLK_k:
- case SDLK_l:
- case SDLK_m:
- case SDLK_n:
- case SDLK_o:
- case SDLK_p:
- case SDLK_q:
- case SDLK_r:
- case SDLK_s:
- case SDLK_t:
- case SDLK_u:
- case SDLK_v:
- case SDLK_w:
- case SDLK_x:
- case SDLK_y:
- case SDLK_z:
- case SDLK_0:
- case SDLK_1:
- case SDLK_2:
- case SDLK_3:
- case SDLK_4:
- case SDLK_5:
- case SDLK_6:
- case SDLK_7:
- case SDLK_8:
- case SDLK_9:
- case SDLK_SLASH:
- case SDLK_BACKSLASH:
- case SDLK_PERIOD:
- case SDLK_COMMA:
- case SDLK_SPACE:
- case SDLK_UNDERSCORE:
- case SDLK_MINUS:
- input += static_cast<char> (lastKey);
- lastResult = NOTHING;
- break;
- case SDLK_RETURN:
- lastResult = ENTERED;
- break;
- case SDLK_ESCAPE:
- lastResult = ESCAPED;
- break;
- }
- return lastResult;
- }
- protected:
- static Result lastResult;
- static String input;
- };
- if(lastKey == SDLK_RETURN)
- lastResult = ENTERED;
- else if(lastKey == SDLK_ESCAPE)
- lastResult = ESCAPED;
- else if(lastKey >= SDLK_SPACE && lastKey <= SDLK_z)
- {
- input += static_cast<char> (lastKey);
- lastResult = NOTHING;
- }
Add Comment
Please, Sign In to add comment