Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 15, 2011, 9:47:11 PM (13 years ago)
Author:
landauf
Message:

merged usability branch back to trunk

incomplete summary of the changes in this branch:

  • enhanced keyboard navigation in GUIs
  • implemented new graphics menu and changeable window size at runtime
  • added developer mode
  • HUD shows if game is paused, game pauses if ingame menu is opened
  • removed a few obsolete commands and hid some that are more for internal use
  • numpad works in console and gui
  • faster loading of level info
  • enhanced usage of compositors (Shader class)
  • improved camera handling, configurable FOV and aspect ratio
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/input/Keyboard.cc

    r6422 r8079  
    3636    {
    3737        // update modifiers
    38         if (arg.key == OIS::KC_RMENU    || arg.key == OIS::KC_LMENU)
    39             modifiers_ |= KeyboardModifier::Alt;   // alt key
    40         if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL)
    41             modifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
    42         if (arg.key == OIS::KC_RSHIFT   || arg.key == OIS::KC_LSHIFT)
    43             modifiers_ |= KeyboardModifier::Shift; // shift key
     38        switch (arg.key)
     39        {
     40            case OIS::KC_RMENU:
     41            case OIS::KC_LMENU:
     42                modifiers_ |= KeyboardModifier::Alt;   // alt key
     43                break;
     44            case OIS::KC_RCONTROL:
     45            case OIS::KC_LCONTROL:
     46                modifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
     47                break;
     48            case OIS::KC_RSHIFT:
     49            case OIS::KC_LSHIFT:
     50                modifiers_ |= KeyboardModifier::Shift; // shift key
     51                break;
     52            case OIS::KC_TAB:
     53                // Do not distribute the alt+tab event (messes with the operating system)
     54                if ((modifiers_ & KeyboardModifier::Alt) != 0)
     55                    return true;
     56            default:;
     57        }
    4458
    45         // Do not distribute the alt+tab event (messes with the operating system)
    46         if ((modifiers_ & KeyboardModifier::Alt) != 0 && arg.key == OIS::KC_TAB)
    47             return true;
    48 
    49         KeyEvent evt(arg);
     59        KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0);
    5060        super::buttonPressed(evt);
    5161        return true;
     
    5666    {
    5767        // update modifiers
    58         if (arg.key == OIS::KC_RMENU    || arg.key == OIS::KC_LMENU)
    59             modifiers_ &= ~KeyboardModifier::Alt;   // alt key
    60         if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL)
    61             modifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
    62         if (arg.key == OIS::KC_RSHIFT   || arg.key == OIS::KC_LSHIFT)
    63             modifiers_ &= ~KeyboardModifier::Shift; // shift key
     68        switch (arg.key)
     69        {
     70            case OIS::KC_RMENU:
     71            case OIS::KC_LMENU:
     72                modifiers_ &= ~KeyboardModifier::Alt;   // alt key
     73                break;
     74            case OIS::KC_RCONTROL:
     75            case OIS::KC_LCONTROL:
     76                modifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
     77                break;
     78            case OIS::KC_RSHIFT:
     79            case OIS::KC_LSHIFT:
     80                modifiers_ &= ~KeyboardModifier::Shift; // shift key
     81                break;
     82            default:;
     83        }
    6484
    65         KeyEvent evt(arg);
     85        KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0);
    6686        super::buttonReleased(evt);
    6787        return true;
    6888    }
     89
     90    /// A map which returns the corresponding chars for some key codes
     91    unsigned int Keyboard::getKeyText(const OIS::KeyEvent& arg)
     92    {
     93        switch (arg.key)
     94        {
     95            case OIS::KC_NUMPAD0:     return static_cast<unsigned int>('0');
     96            case OIS::KC_NUMPAD1:     return static_cast<unsigned int>('1');
     97            case OIS::KC_NUMPAD2:     return static_cast<unsigned int>('2');
     98            case OIS::KC_NUMPAD3:     return static_cast<unsigned int>('3');
     99            case OIS::KC_NUMPAD4:     return static_cast<unsigned int>('4');
     100            case OIS::KC_NUMPAD5:     return static_cast<unsigned int>('5');
     101            case OIS::KC_NUMPAD6:     return static_cast<unsigned int>('6');
     102            case OIS::KC_NUMPAD7:     return static_cast<unsigned int>('7');
     103            case OIS::KC_NUMPAD8:     return static_cast<unsigned int>('8');
     104            case OIS::KC_NUMPAD9:     return static_cast<unsigned int>('9');
     105            case OIS::KC_DECIMAL:     return static_cast<unsigned int>('.');
     106            case OIS::KC_DIVIDE:      return static_cast<unsigned int>('/');
     107            case OIS::KC_NUMPADENTER: return static_cast<unsigned int>('\n');
     108            default:                  return arg.text;
     109        }
     110    }
    69111}
Note: See TracChangeset for help on using the changeset viewer.