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.

84 lines
1.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include <stdio.h>
  8. #include <VGUI_Controls.h>
  9. #include "filesystem.h"
  10. #include "HelpText.h"
  11. using namespace vgui;
  12. //-----------------------------------------------------------------------------
  13. // Purpose: Constructor
  14. //-----------------------------------------------------------------------------
  15. CHelpText::CHelpText(const char *mod)
  16. {
  17. char configName[200];
  18. _snprintf(configName,200,"Admin\\HelpFile_%s.vdf",mod);
  19. m_pHelpData = new KeyValues ("Help");
  20. // always load the basic definiton
  21. LoadHelpFile("Admin\\HelpFile.vdf");
  22. // now load mod specific stuff
  23. if( g_pFullFileSystem->FileExists(configName) )
  24. {
  25. LoadHelpFile(configName);
  26. }
  27. // and load an admin mod page if you can find it
  28. if( g_pFullFileSystem->FileExists("Admin\\HelpFile_adminmod.vdf") )
  29. {
  30. LoadHelpFile("Admin\\HelpFile_adminmod.vdf");
  31. }
  32. }
  33. //-----------------------------------------------------------------------------
  34. // Purpose: Destructor
  35. //-----------------------------------------------------------------------------
  36. CHelpText::~CHelpText()
  37. {
  38. m_pHelpData->deleteThis();
  39. }
  40. void CHelpText::LoadHelpFile(const char *filename)
  41. {
  42. if (!m_pHelpData->LoadFromFile(g_pFullFileSystem, filename, true, "PLATFORM"))
  43. {
  44. // failed to load...
  45. }
  46. else
  47. {
  48. }
  49. }
  50. const char *CHelpText::GetHelp(const char *keyname)
  51. {
  52. KeyValues *help = m_pHelpData->FindKey(keyname, true);
  53. if(help)
  54. {
  55. return help->GetString("text");
  56. }
  57. else
  58. {
  59. return NULL;
  60. }
  61. }