Counter Strike : Global Offensive Source Code
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.

76 lines
2.4 KiB

  1. //========= Copyright � 1996-2003, Valve LLC, All rights reserved. ============
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #ifndef COMMANDMENU_H
  8. #define COMMANDMENU_H
  9. #include <vgui_controls/Menu.h>
  10. #include <game/client/iviewport.h>
  11. #include <filesystem.h>
  12. #include "utlstack.h"
  13. #include "utlvector.h"
  14. #include <keyvalues.h>
  15. using namespace vgui;
  16. class CommandMenu : public Menu
  17. {
  18. private:
  19. DECLARE_CLASS_SIMPLE( CommandMenu, Menu );
  20. typedef struct
  21. {
  22. Menu * menu;
  23. int itemnr;
  24. } CommandMenuItem;
  25. public:
  26. CommandMenu( Panel *parent, const char *panelName, IViewPort * viewport );
  27. ~CommandMenu();
  28. bool LoadFromFile(const char * fileName); // load menu from file (via KeyValues)
  29. void UpdateMenu(); // call to update all menu items, check buttons etc
  30. void RebuildMenu(); // rebuilds menu respecting changed game state (map, team etc)
  31. void ClearMenu(); // destroy menu
  32. public:
  33. // overwrite these in your derived class
  34. // virtual CommandMenu * CommandMenu::Factory(Panel *parent, const char *panelName, IViewPort * viewport = NULL, IFileSystem * pFileSytem = NULL); // overwrite
  35. virtual int AddCustomItem(KeyValues * params, Menu * menu) {return 0;} // return MenuItem nr
  36. virtual void UpdateCustomItem(KeyValues * params, MenuItem * item ) {}; // maybe change your item
  37. virtual void OnCustomItem(KeyValues * params) {}; // a custom item was pressed
  38. virtual bool CheckRules(const char *rule, const char *ruledata); // check a menu item rule
  39. virtual void SetVisible(bool state);
  40. // DON'T touch anything below !
  41. protected:
  42. void OnMessage(const KeyValues *params, VPANEL fromPanel);
  43. void StartNewSubMenu(KeyValues * params);
  44. void FinishSubMenu();
  45. void AddMenuCommandItem(KeyValues * params);
  46. void AddMenuCustomItem(KeyValues * params);
  47. void AddMenuToggleItem(KeyValues * params);
  48. bool LoadFromKeyValuesInternal(KeyValues * key, int depth);
  49. bool LoadFromKeyValues( KeyValues * key); //
  50. KeyValues * GetKeyValues(); // returns keyValues for current menu or NULL
  51. IViewPort * m_ViewPort; // viewport interface
  52. Menu * m_CurrentMenu; // Current menu while building CommandComoboBox
  53. char m_CurrentTeam[4];
  54. char m_CurrentMap[256];
  55. KeyValues* m_MenuKeys;
  56. CUtlStack<vgui::Menu*>m_pMenuStack;
  57. CUtlVector<CommandMenuItem>m_MenuItems;
  58. };
  59. #endif // COMMANDMENU_H