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.

56 lines
1.3 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef PANELHANDLE_H
  6. #define PANELHANDLE_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "tier0/platform.h"
  11. namespace panorama
  12. {
  13. const uint64 k_ulInvalidPanelHandle64 = 0x00000000FFFFFFFF;
  14. //
  15. // Safe handle to a panel. To get pointer to actual panel, call IUIEngine::GetPanelPtr
  16. //
  17. struct PanelHandle_t
  18. {
  19. int32 m_iPanelIndex; // index into panel map
  20. uint32 m_unSerialNumber; // unique number used to ensure that panel at m_iPanelIndex is still the panel we originally pointed to
  21. bool operator<( const PanelHandle_t &rhs ) const
  22. {
  23. if ( m_iPanelIndex != rhs.m_iPanelIndex )
  24. return m_iPanelIndex < rhs.m_iPanelIndex;
  25. return m_unSerialNumber < rhs.m_unSerialNumber;
  26. }
  27. bool operator==( const PanelHandle_t &rhs ) const
  28. {
  29. return (m_iPanelIndex == rhs.m_iPanelIndex) && (m_unSerialNumber == rhs.m_unSerialNumber);
  30. }
  31. bool operator!=( const PanelHandle_t &rhs ) const
  32. {
  33. return !(*this == rhs);
  34. }
  35. static const PanelHandle_t &InvalidHandle()
  36. {
  37. static PanelHandle_t s_invalid = { k_ulInvalidPanelHandle64 >> 32, 0xffffffff & k_ulInvalidPanelHandle64 };
  38. return s_invalid;
  39. }
  40. };
  41. } // namespace panorama
  42. #endif // PANELHANDLE_H