KeyboardMenu Class Reference

#include <keyboard_menu.hpp>

Inherits Menu.

List of all members.

Public Member Functions

 KeyboardMenu (JoystickKeyboardController *controller)
 ~KeyboardMenu ()
void update ()
std::string get_key_name (SDLKey key)
virtual void menu_action (MenuItem *item)
void check_menu ()

Public Attributes

JoystickKeyboardControllercontroller

Private Member Functions

 KeyboardMenu (const KeyboardMenu &)
KeyboardMenuoperator= (const KeyboardMenu &)


Detailed Description

Definition at line 24 of file keyboard_menu.hpp.


Constructor & Destructor Documentation

KeyboardMenu::KeyboardMenu ( JoystickKeyboardController controller  ) 

Definition at line 24 of file keyboard_menu.cpp.

References _(), Controller::ACTION, Menu::add_back(), Menu::add_controlfield(), Menu::add_hl(), Menu::add_label(), Menu::add_toggle(), Controller::CONSOLE, Config::console_enabled, Controller::CONTROLCOUNT, controller, Controller::DOWN, g_config, Controller::JUMP, JoystickKeyboardController::jump_with_up_kbd, Controller::LEFT, Controller::PEEK_DOWN, Controller::PEEK_LEFT, Controller::PEEK_RIGHT, Controller::PEEK_UP, Controller::RIGHT, Controller::UP, and update().

00024                                                                   :
00025   controller(_controller)
00026 {
00027   add_label(_("Setup Keyboard"));
00028   add_hl();
00029   add_controlfield(Controller::UP,         _("Up"));
00030   add_controlfield(Controller::DOWN,       _("Down"));
00031   add_controlfield(Controller::LEFT,       _("Left"));
00032   add_controlfield(Controller::RIGHT,      _("Right"));
00033   add_controlfield(Controller::JUMP,       _("Jump"));
00034   add_controlfield(Controller::ACTION,     _("Action"));
00035   add_controlfield(Controller::PEEK_LEFT,  _("Peek Left"));
00036   add_controlfield(Controller::PEEK_RIGHT, _("Peek Right"));
00037   add_controlfield(Controller::PEEK_UP,    _("Peek Up"));
00038   add_controlfield(Controller::PEEK_DOWN,  _("Peek Down"));
00039   if (g_config->console_enabled) {
00040     add_controlfield(Controller::CONSOLE, _("Console"));
00041   }
00042   add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), controller->jump_with_up_kbd);
00043   add_hl();
00044   add_back(_("Back"));
00045   update();
00046 }

KeyboardMenu::~KeyboardMenu (  ) 

Definition at line 48 of file keyboard_menu.cpp.

00049 {}

KeyboardMenu::KeyboardMenu ( const KeyboardMenu  )  [private]


Member Function Documentation

void KeyboardMenu::update (  ) 

Reimplemented from Menu.

Definition at line 98 of file keyboard_menu.cpp.

References Controller::ACTION, MenuItem::change_input(), Controller::CONSOLE, Config::console_enabled, Controller::CONTROLCOUNT, controller, Controller::DOWN, g_config, Menu::get_item_by_id(), get_key_name(), Controller::JUMP, JoystickKeyboardController::jump_with_up_kbd, Controller::LEFT, Controller::PEEK_DOWN, Controller::PEEK_LEFT, Controller::PEEK_RIGHT, Controller::PEEK_UP, JoystickKeyboardController::reversemap_key(), Controller::RIGHT, MenuItem::toggled, and Controller::UP.

Referenced by KeyboardMenu(), and JoystickKeyboardController::process_menu_key_event().

00099 {
00100   // update menu
00101   get_item_by_id((int) Controller::UP).change_input(get_key_name(
00102                                                       controller->reversemap_key(Controller::UP)));
00103   get_item_by_id((int) Controller::DOWN).change_input(get_key_name(
00104                                                         controller->reversemap_key(Controller::DOWN)));
00105   get_item_by_id((int) Controller::LEFT).change_input(get_key_name(
00106                                                         controller->reversemap_key(Controller::LEFT)));
00107   get_item_by_id((int) Controller::RIGHT).change_input(get_key_name(
00108                                                          controller->reversemap_key(Controller::RIGHT)));
00109   get_item_by_id((int) Controller::JUMP).change_input(get_key_name(
00110                                                         controller->reversemap_key(Controller::JUMP)));
00111   get_item_by_id((int) Controller::ACTION).change_input(get_key_name(
00112                                                           controller->reversemap_key(Controller::ACTION)));
00113   get_item_by_id((int) Controller::PEEK_LEFT).change_input(get_key_name(
00114                                                              controller->reversemap_key(Controller::PEEK_LEFT)));
00115   get_item_by_id((int) Controller::PEEK_RIGHT).change_input(get_key_name(
00116                                                               controller->reversemap_key(Controller::PEEK_RIGHT)));
00117   get_item_by_id((int) Controller::PEEK_UP).change_input(get_key_name(
00118                                                            controller->reversemap_key(Controller::PEEK_UP)));
00119   get_item_by_id((int) Controller::PEEK_DOWN).change_input(get_key_name(
00120                                                              controller->reversemap_key(Controller::PEEK_DOWN)));
00121   if (g_config->console_enabled) {
00122     get_item_by_id((int) Controller::CONSOLE).change_input(get_key_name(
00123                                                              controller->reversemap_key(Controller::CONSOLE)));
00124   }
00125   get_item_by_id(Controller::CONTROLCOUNT).toggled = controller->jump_with_up_kbd;
00126 }

std::string KeyboardMenu::get_key_name ( SDLKey  key  ) 

Definition at line 52 of file keyboard_menu.cpp.

References _().

Referenced by update().

00053 {
00054   switch(key) {
00055     case SDLK_UNKNOWN:
00056       return _("None");
00057     case SDLK_UP:
00058       return _("Up cursor");
00059     case SDLK_DOWN:
00060       return _("Down cursor");
00061     case SDLK_LEFT:
00062       return _("Left cursor");
00063     case SDLK_RIGHT:
00064       return _("Right cursor");
00065     case SDLK_RETURN:
00066       return _("Return");
00067     case SDLK_SPACE:
00068       return _("Space");
00069     case SDLK_RSHIFT:
00070       return _("Right Shift");
00071     case SDLK_LSHIFT:
00072       return _("Left Shift");
00073     case SDLK_RCTRL:
00074       return _("Right Control");
00075     case SDLK_LCTRL:
00076       return _("Left Control");
00077     case SDLK_RALT:
00078       return _("Right Alt");
00079     case SDLK_LALT:
00080       return _("Left Alt");
00081     default:
00082       return SDL_GetKeyName((SDLKey) key);
00083   }
00084 }

void KeyboardMenu::menu_action ( MenuItem item  )  [virtual]

Reimplemented from Menu.

Definition at line 87 of file keyboard_menu.cpp.

References _(), MenuItem::change_input(), Controller::CONTROLCOUNT, controller, MenuItem::id, JoystickKeyboardController::jump_with_up_kbd, MenuItem::toggled, and JoystickKeyboardController::wait_for_key.

00088 {
00089   if(item->id >= 0 && item->id < Controller::CONTROLCOUNT){
00090     item->change_input(_("Press Key"));
00091     controller->wait_for_key = item->id;
00092   } else if( item->id == Controller::CONTROLCOUNT) {
00093     controller->jump_with_up_kbd = item->toggled;
00094   } 
00095 }

void KeyboardMenu::check_menu (  )  [inline, virtual]

Implements Menu.

Definition at line 34 of file keyboard_menu.hpp.

00034 {}

KeyboardMenu& KeyboardMenu::operator= ( const KeyboardMenu  )  [private]


Member Data Documentation

JoystickKeyboardController* KeyboardMenu::controller

Definition at line 33 of file keyboard_menu.hpp.

Referenced by KeyboardMenu(), menu_action(), and update().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:31 2014 for SuperTux by  doxygen 1.5.1