summaryrefslogtreecommitdiff
path: root/serverbrowser/ModList.h
blob: b899ad90ae93d9970484e8ad8de11aaa32bbc7cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================

#ifndef MODLIST_H
#define MODLIST_H
#ifdef _WIN32
#pragma once
#endif

//-----------------------------------------------------------------------------
// Purpose: Handles parsing of half-life directory for mod info
//-----------------------------------------------------------------------------
class CModList
{
public:
	CModList();

	int GetIndex( const CGameID &iAppID ) const;
	void AddVGUIListener( vgui::VPANEL panel );

	// returns number of mods 
	int ModCount();

	// returns the full name of the mod, index valid in range [0, ModCount)
	const char *GetModName( int index );

	// returns mod directory string
	const char *GetModDir( int index );

	const CGameID &GetAppID( int index ) const;

	// returns the mod name for the associated gamedir
	const char *GetModNameForModDir( const CGameID &iAppID );

private:
	struct mod_t
	{
		char description[64];
		char gamedir[64];
		CGameID	m_GameID;
		int m_InternalAppId;
		bool operator==( const mod_t& rhs ) const { return rhs.m_GameID == m_GameID; }
	};

	static int ModNameCompare( const mod_t *pLeft, const mod_t *pRight );
	void ParseInstalledMods();
	void ParseSteamMods();
	int LoadAppConfiguration( uint32 nAppID );

	CUtlVector<mod_t> m_ModList;
	CUtlVector<vgui::VPANEL> m_VGUIListeners;
};

// singleton accessor
extern CModList &ModList();


#endif // MODLIST_H