Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef OPTIONS_SUB_KEYBOARD_H
  8. #define OPTIONS_SUB_KEYBOARD_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "utlvector.h"
  13. #include "utlsymbol.h"
  14. #include <vgui_controls/PropertyPage.h>
  15. class VControlsListPanel;
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Keyboard Details, Part of OptionsDialog
  18. //-----------------------------------------------------------------------------
  19. class COptionsSubKeyboard : public vgui::PropertyPage
  20. {
  21. DECLARE_CLASS_SIMPLE( COptionsSubKeyboard, vgui::PropertyPage );
  22. public:
  23. COptionsSubKeyboard(vgui::Panel *parent);
  24. ~COptionsSubKeyboard();
  25. virtual void OnResetData();
  26. virtual void OnApplyChanges();
  27. virtual void OnKeyCodePressed( vgui::KeyCode code );
  28. virtual void OnThink();
  29. // Trap row selection message
  30. MESSAGE_FUNC_INT( ItemSelected, "ItemSelected", itemID );
  31. private:
  32. void Finish( ButtonCode_t code );
  33. //-----------------------------------------------------------------------------
  34. // Purpose: Used for saving engine keybindings in case user hits cancel button
  35. //-----------------------------------------------------------------------------
  36. struct KeyBinding
  37. {
  38. char *binding;
  39. };
  40. // Create the key binding list control
  41. void CreateKeyBindingList( void );
  42. virtual void OnCommand( const char *command );
  43. // Tell engine to bind/unbind a key
  44. void BindKey( const char *key, const char *binding );
  45. void UnbindKey( const char *key );
  46. // Save/restore/cleanup engine's current bindings ( for handling cancel button )
  47. void SaveCurrentBindings( void );
  48. void DeleteSavedBindings( void );
  49. // Get column 0 action descriptions for all keys
  50. void ParseActionDescriptions( void );
  51. // Populate list of actions with current engine keybindings
  52. void FillInCurrentBindings( void );
  53. // Remove all current bindings from list of bindings
  54. void ClearBindItems( void );
  55. // Fill in bindings with mod-specified defaults
  56. void FillInDefaultBindings( void );
  57. // Copy bindings out of list and set them in the engine
  58. void ApplyAllBindings( void );
  59. // Bind a key to the item
  60. void AddBinding( KeyValues *item, const char *keyname );
  61. // Remove all instances of a key from all bindings
  62. void RemoveKeyFromBindItems( KeyValues *org_item, const char *key );
  63. // Find item by binding name
  64. KeyValues *GetItemForBinding( const char *binding );
  65. private:
  66. void OpenKeyboardAdvancedDialog();
  67. vgui::DHANDLE<class COptionsSubKeyboardAdvancedDlg> m_OptionsSubKeyboardAdvancedDlg;
  68. virtual void OnKeyCodeTyped(vgui::KeyCode code);
  69. VControlsListPanel *m_pKeyBindList;
  70. vgui::Button *m_pSetBindingButton;
  71. vgui::Button *m_pClearBindingButton;
  72. // List of saved bindings for the keys
  73. KeyBinding m_Bindings[ BUTTON_CODE_LAST ];
  74. // List of all the keys that need to have their binding removed
  75. CUtlVector<CUtlSymbol> m_KeysToUnbind;
  76. };
  77. #endif // OPTIONS_SUB_KEYBOARD_H