//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================


#include <stdio.h>

#include <VGUI_Controls.h>
#include "FileSystem.h"
#include "HelpText.h"
using namespace vgui;

//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CHelpText::CHelpText(const char *mod) 
{

	char configName[200];
	_snprintf(configName,200,"Admin\\HelpFile_%s.vdf",mod);
	
	m_pHelpData = new KeyValues ("Help");	
	
	// always load the basic definiton
	LoadHelpFile("Admin\\HelpFile.vdf");
	
	// now load mod specific stuff
	if( filesystem()->FileExists(configName) )
	{
		LoadHelpFile(configName);	
	} 

	// and load an admin mod page if you can find it
	if( filesystem()->FileExists("Admin\\HelpFile_adminmod.vdf") )
	{
		LoadHelpFile("Admin\\HelpFile_adminmod.vdf");	
	}

}

//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
CHelpText::~CHelpText()
{
	m_pHelpData->deleteThis();
}


void CHelpText::LoadHelpFile(const char *filename)
{


	if (!m_pHelpData->LoadFromFile(filesystem(), filename, true, "PLATFORM"))
	{
		// failed to load...
	}
	else
	{
		
	}

}

const char *CHelpText::GetHelp(const char *keyname)
{
	KeyValues *help = m_pHelpData->FindKey(keyname, true);
	if(help)
	{
		return help->GetString("text");
	}
	else
	{
		return NULL;
	}
}





