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.

124 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "pch_serverbrowser.h"
  8. //-----------------------------------------------------------------------------
  9. // Purpose: Singleton accessor
  10. //-----------------------------------------------------------------------------
  11. CModList &ModList()
  12. {
  13. static CModList s_ModList;
  14. return s_ModList;
  15. }
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Constructor
  18. //-----------------------------------------------------------------------------
  19. CModList::CModList()
  20. {
  21. ParseSteamMods();
  22. }
  23. //-----------------------------------------------------------------------------
  24. // Purpose: returns number of mods
  25. //-----------------------------------------------------------------------------
  26. int CModList::ModCount()
  27. {
  28. return m_ModList.Count();
  29. }
  30. //-----------------------------------------------------------------------------
  31. // Purpose: data accessor
  32. //-----------------------------------------------------------------------------
  33. const char *CModList::GetModName(int index)
  34. {
  35. return m_ModList[index].description;
  36. }
  37. //-----------------------------------------------------------------------------
  38. // Purpose: data accessor
  39. //-----------------------------------------------------------------------------
  40. const char *CModList::GetModDir(int index)
  41. {
  42. return m_ModList[index].gamedir;
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose: data accessor
  46. //-----------------------------------------------------------------------------
  47. const CGameID &CModList::GetAppID(int index) const
  48. {
  49. return m_ModList[index].m_GameID;
  50. }
  51. //-----------------------------------------------------------------------------
  52. // Purpose: get the modlist index for this app id
  53. //-----------------------------------------------------------------------------
  54. int CModList::GetIndex( const CGameID &iAppID ) const
  55. {
  56. mod_t mod;
  57. mod.m_GameID = iAppID;
  58. return m_ModList.Find( mod );
  59. }
  60. //-----------------------------------------------------------------------------
  61. // Purpose: returns the mod name for the associated gamedir
  62. //-----------------------------------------------------------------------------
  63. const char *CModList::GetModNameForModDir( const CGameID &gameID )
  64. {
  65. int iApp = GetIndex( gameID );
  66. if ( iApp != m_ModList.InvalidIndex() )
  67. {
  68. return m_ModList[iApp].description;
  69. }
  70. if ( ServerBrowserDialog().GetActiveModName() )
  71. {
  72. return ServerBrowserDialog().GetActiveGameName();
  73. }
  74. return "";
  75. }
  76. //-----------------------------------------------------------------------------
  77. // Purpose: sort the mod list in alphabetical order
  78. //-----------------------------------------------------------------------------
  79. int CModList::ModNameCompare( const mod_t *pLeft, const mod_t *pRight )
  80. {
  81. return ( Q_stricmp( pLeft->description, pRight->description ) );
  82. }
  83. //-----------------------------------------------------------------------------
  84. // Purpose: gets list of steam games we can filter for
  85. //-----------------------------------------------------------------------------
  86. void CModList::ParseSteamMods()
  87. {
  88. }
  89. //-----------------------------------------------------------------------------
  90. // Purpose: load settings for an app
  91. //-----------------------------------------------------------------------------
  92. int CModList::LoadAppConfiguration( uint32 nAppID )
  93. {
  94. return -1;
  95. }
  96. //-----------------------------------------------------------------------------
  97. // Purpose: add a vgui panel to message when the app list changes
  98. //-----------------------------------------------------------------------------
  99. void CModList::AddVGUIListener( vgui::VPANEL panel )
  100. {
  101. m_VGUIListeners.AddToTail( panel );
  102. }