Subversion Repositories spk

Rev

Rev 94 | Rev 101 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 95
Line 1... Line 1...
1
 
1
 
2
#include "GameDirectories.h"
2
#include "GameDirectories.h"
3
#include "GameExe.h"
3
#include "GameExe.h"
4
#include "Packages.h"
4
#include "Packages.h"
-
 
5
#include "GameExe.h"
5
 
6
 
6
namespace SPK {
7
namespace SPK {
7
 
8
 
8
	CGameDirectories::CGameDirectories(void) : _pSelected(NULL),
9
	CGameDirectories::CGameDirectories(const Utils::String &mydoc) : _pSelected(NULL),
9
		_pCurrentItr(NULL),
10
		_pCurrentItr(NULL),
10
		_iLanguage(0)
11
		_iLanguage(0)
11
	{
12
	{
12
		_pDirs = new std::vector<SGameDir *>();
13
		_pDirs = new std::vector<SGameDir *>();
-
 
14
 
-
 
15
		_updateControlledDirs(mydoc);
13
	}
16
	}
14
 
17
 
15
	CGameDirectories::~CGameDirectories(void)
18
	CGameDirectories::~CGameDirectories(void)
16
	{
19
	{
17
		clear();
20
		clear();
18
		delete _pDirs;
21
		delete _pDirs;
-
 
22
		_lControlledDirs.MemoryClear();
19
	}
23
	}
20
 
24
 
21
	bool CGameDirectories::add(const Utils::String &dir, const Utils::String &name, int iGame, const Utils::String &addon, bool bLoad)
25
	bool CGameDirectories::add(const Utils::String &dir, const Utils::String &name, int iGame, const Utils::String &addon, bool bLoad)
22
	{
26
	{
23
		for ( std::vector<SGameDir *>::iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++ ) {
27
		for ( std::vector<SGameDir *>::iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++ ) {
Line 172... Line 176...
172
	{
176
	{
173
		if ( _pSelected ) return _pSelected->pVfs;
177
		if ( _pSelected ) return _pSelected->pVfs;
174
		return NULL;
178
		return NULL;
175
	}
179
	}
176
 
180
 
-
 
181
	void CGameDirectories::syncWithControlled(CGameExe *exe)
-
 
182
	{
-
 
183
		for(CListNode<Utils::SStringList> *node = _lControlledDirs.Front(); node; node = node->next()) {
-
 
184
			Utils::SStringList *str = node->Data();
-
 
185
			add(exe->GetProperDir(str->str), str->data, exe->GetGameType(str->str), exe->GetAddonDir(str->str), true);
-
 
186
		}
-
 
187
	}
-
 
188
 
177
	Utils::String CGameDirectories::findText(int iLanguage, int iPage, int iID, Utils::String missing)
189
	Utils::String CGameDirectories::findText(int iLanguage, int iPage, int iID, Utils::String missing)
178
	{
190
	{
179
		if ( iLanguage == 0 ) iLanguage = _iLanguage;
191
		if ( iLanguage == 0 ) iLanguage = _iLanguage;
180
		if ( _pSelected ) {
192
		if ( _pSelected ) {
181
			if ( _pSelected->pVfs->textExists(iLanguage, iPage, iID) ) {
193
			if ( _pSelected->pVfs->textExists(iLanguage, iPage, iID) ) {
Line 360... Line 372...
360
		gd->pVfs->LoadFilesystem(gd->dir);
372
		gd->pVfs->LoadFilesystem(gd->dir);
361
		gd->pVfs->SetAddon(addon);
373
		gd->pVfs->SetAddon(addon);
362
 
374
 
363
		_pDirs->push_back(gd);
375
		_pDirs->push_back(gd);
364
	}
376
	}
-
 
377
 
-
 
378
	void CGameDirectories::_updateControlledDirs(const Utils::String &mydoc)
-
 
379
	{
-
 
380
		_lControlledDirs.MemoryClear();
-
 
381
 
-
 
382
		CFileIO configFile(mydoc + "/Egosoft/pluginmanager.dat");
-
 
383
		if ( configFile.startRead() ) {
-
 
384
			while(!configFile.atEnd()) {
-
 
385
				Utils::String line = configFile.readEndOfLine();
-
 
386
				if ( line.token(":", 1).Compare("DirExe") ) {
-
 
387
					Utils::String rest = line.tokens(":", 2).removeFirstSpace();
-
 
388
					if ( rest.countToken("|" ) > 2 )
-
 
389
						_lControlledDirs.pushBack(rest.token("|", 3), rest.token("|", 2));
-
 
390
					else
-
 
391
						_lControlledDirs.pushBack(rest.token("|", 2), rest.token("|", 1));
-
 
392
				}
-
 
393
			}
-
 
394
		}
-
 
395
	}
365
}
396
}