| 94 | cycrow | 1 |   | 
        
           |  |  | 2 | #include "GameDirectories.h"
 | 
        
           |  |  | 3 | #include "GameExe.h"
 | 
        
           |  |  | 4 | #include "Packages.h"
 | 
        
           | 95 | cycrow | 5 | #include "GameExe.h"
 | 
        
           | 94 | cycrow | 6 |   | 
        
           |  |  | 7 | namespace SPK {
 | 
        
           |  |  | 8 |   | 
        
           | 197 | cycrow | 9 | 	CGameDirectories::CGameDirectories(const Utils::WString &mydoc) : _pSelected(NULL),
 | 
        
           | 94 | cycrow | 10 | 		_pCurrentItr(NULL),
 | 
        
           |  |  | 11 | 		_iLanguage(0)
 | 
        
           |  |  | 12 | 	{
 | 
        
           |  |  | 13 | 		_pDirs = new std::vector<SGameDir *>();
 | 
        
           | 95 | cycrow | 14 |   | 
        
           |  |  | 15 | 		_updateControlledDirs(mydoc);
 | 
        
           | 94 | cycrow | 16 | 	}
 | 
        
           |  |  | 17 |   | 
        
           |  |  | 18 | 	CGameDirectories::~CGameDirectories(void)
 | 
        
           |  |  | 19 | 	{
 | 
        
           |  |  | 20 | 		clear();
 | 
        
           |  |  | 21 | 		delete _pDirs;
 | 
        
           | 112 | cycrow | 22 | 		_lControlledDirs.clear();
 | 
        
           | 94 | cycrow | 23 | 	}
 | 
        
           |  |  | 24 |   | 
        
           | 197 | cycrow | 25 | 	bool CGameDirectories::add(const Utils::WString &dir, const Utils::WString &name, int iGame, const Utils::WString &addon, bool bLoad)
 | 
        
           | 94 | cycrow | 26 | 	{
 | 
        
           |  |  | 27 | 		for ( std::vector<SGameDir *>::iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++ ) {
 | 
        
           |  |  | 28 | 			if ( dir.Compare((*itr)->dir) ) return false;
 | 
        
           |  |  | 29 | 		}
 | 
        
           |  |  | 30 |   | 
        
           |  |  | 31 | 		_add(dir, name, iGame, addon, bLoad);
 | 
        
           |  |  | 32 | 		return true;
 | 
        
           |  |  | 33 | 	}
 | 
        
           |  |  | 34 |   | 
        
           | 197 | cycrow | 35 | 	bool CGameDirectories::remove(const Utils::WString &dir)
 | 
        
           | 94 | cycrow | 36 | 	{
 | 
        
           |  |  | 37 | 		for ( std::vector<SGameDir *>::iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++ ) {
 | 
        
           |  |  | 38 | 			if ( dir.Compare((*itr)->dir) ) {
 | 
        
           |  |  | 39 | 				delete (*itr);
 | 
        
           |  |  | 40 | 				_pDirs->erase(itr);
 | 
        
           |  |  | 41 | 				return true;
 | 
        
           |  |  | 42 | 			}
 | 
        
           |  |  | 43 | 		}
 | 
        
           |  |  | 44 |   | 
        
           |  |  | 45 | 		return false;
 | 
        
           |  |  | 46 | 	}
 | 
        
           |  |  | 47 |   | 
        
           | 197 | cycrow | 48 | 	bool CGameDirectories::findDir(const Utils::WString &dir)
 | 
        
           | 94 | cycrow | 49 | 	{
 | 
        
           |  |  | 50 | 		SGameDir *d = _findGameDir(dir);
 | 
        
           |  |  | 51 | 		if ( d ) {
 | 
        
           |  |  | 52 | 			_pCurrentItr = d;
 | 
        
           |  |  | 53 | 			return true;
 | 
        
           |  |  | 54 | 		}
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 | 		return false;
 | 
        
           |  |  | 57 | 	}
 | 
        
           |  |  | 58 |   | 
        
           | 197 | cycrow | 59 | 	bool CGameDirectories::parse(const Utils::WString &data, CPackages *pPackages)
 | 
        
           | 94 | cycrow | 60 | 	{
 | 
        
           | 197 | cycrow | 61 | 		int iGame = data.token(L";", 2).tokens(L" ", 1).toLong();
 | 
        
           |  |  | 62 | 		SGameExe *exe = pPackages->GetGameExe()->game(iGame);
 | 
        
           |  |  | 63 | 		_add(data.token(L";", 1), data.token(L";", 2).tokens(L" ", 2), iGame, (exe) ? exe->sAddon : Utils::WString::Null(), data.token(L";", 3).toBool());
 | 
        
           | 94 | cycrow | 64 |   | 
        
           |  |  | 65 | 		return true;
 | 
        
           |  |  | 66 | 	}
 | 
        
           |  |  | 67 |   | 
        
           | 227 | cycrow | 68 | 	bool CGameDirectories::writeData(Utils::WStringList* lines)
 | 
        
           | 94 | cycrow | 69 | 	{
 | 
        
           |  |  | 70 | 		bool writeAny = false;
 | 
        
           | 227 | cycrow | 71 | 		for (std::vector<SGameDir*>::const_iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++) {
 | 
        
           |  |  | 72 | 			SGameDir* gd = *itr;
 | 
        
           | 197 | cycrow | 73 | 			lines->pushBack(L"GameDir:" + gd->dir + L";" + Utils::WString::Number(gd->iGame) + L" " + gd->name + ((gd->bLoad) ? L";1" : L";0"));
 | 
        
           | 94 | cycrow | 74 | 			writeAny = true;
 | 
        
           |  |  | 75 | 		}
 | 
        
           |  |  | 76 |   | 
        
           |  |  | 77 | 		return writeAny;
 | 
        
           |  |  | 78 | 	}
 | 
        
           |  |  | 79 |   | 
        
           | 227 | cycrow | 80 | 	bool CGameDirectories::writeData(std::vector<Utils::WString> &lines)
 | 
        
           |  |  | 81 | 	{
 | 
        
           |  |  | 82 | 		bool writeAny = false;
 | 
        
           |  |  | 83 | 		for (std::vector<SGameDir*>::const_iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++) {
 | 
        
           |  |  | 84 | 			SGameDir* gd = *itr;
 | 
        
           |  |  | 85 | 			lines.push_back(L"GameDir:" + gd->dir + L";" + Utils::WString::Number(gd->iGame) + L" " + gd->name + ((gd->bLoad) ? L";1" : L";0"));
 | 
        
           |  |  | 86 | 			writeAny = true;
 | 
        
           |  |  | 87 | 		}
 | 
        
           |  |  | 88 |   | 
        
           |  |  | 89 | 		return writeAny;
 | 
        
           |  |  | 90 | 	}
 | 
        
           |  |  | 91 |   | 
        
           | 101 | cycrow | 92 | 	void CGameDirectories::updateCurrentVFS(bool bReload)
 | 
        
           | 94 | cycrow | 93 | 	{
 | 
        
           |  |  | 94 | 		if ( !_pCurrentItr ) return;
 | 
        
           |  |  | 95 |   | 
        
           | 101 | cycrow | 96 | 		// dont load text if its already been loaded, unless we need to reload them
 | 
        
           |  |  | 97 | 		if ( !bReload && _pCurrentItr->pVfs->isTextUpdated() ) return;
 | 
        
           |  |  | 98 |   | 
        
           |  |  | 99 | 		// update the texts for all pages
 | 
        
           | 94 | cycrow | 100 | 		_pCurrentItr->pVfs->updateTexts(0);
 | 
        
           |  |  | 101 | 	}
 | 
        
           |  |  | 102 |   | 
        
           |  |  | 103 | 	void CGameDirectories::clear()
 | 
        
           |  |  | 104 | 	{
 | 
        
           |  |  | 105 | 		for ( std::vector<SGameDir *>::iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++ ) {
 | 
        
           |  |  | 106 | 			delete *itr;
 | 
        
           |  |  | 107 | 		}
 | 
        
           |  |  | 108 | 		_pDirs->clear();
 | 
        
           |  |  | 109 | 	}
 | 
        
           |  |  | 110 |   | 
        
           |  |  | 111 | 	bool CGameDirectories::setSelectedGameDirectory(int iGame, bool temp)
 | 
        
           |  |  | 112 | 	{
 | 
        
           |  |  | 113 | 		_pTemporary = NULL;
 | 
        
           |  |  | 114 | 		if ( temp ) _pTemporary = _pSelected;
 | 
        
           |  |  | 115 | 		_pSelected = _findGameDir(iGame);
 | 
        
           |  |  | 116 | 		return hasSelected();
 | 
        
           |  |  | 117 | 	}
 | 
        
           |  |  | 118 |   | 
        
           | 197 | cycrow | 119 | 	bool CGameDirectories::setSelectedDirectory(const Utils::WString &dir, bool temp)
 | 
        
           | 94 | cycrow | 120 | 	{
 | 
        
           |  |  | 121 | 		_pTemporary = NULL;
 | 
        
           |  |  | 122 | 		if ( temp ) _pTemporary = _pSelected;
 | 
        
           |  |  | 123 | 		_pSelected = _findGameDir(dir);
 | 
        
           |  |  | 124 | 		return hasSelected();
 | 
        
           |  |  | 125 | 	}
 | 
        
           |  |  | 126 |   | 
        
           |  |  | 127 | 	void CGameDirectories::reselectTemporaryDirectory()
 | 
        
           |  |  | 128 | 	{
 | 
        
           |  |  | 129 | 		if ( _pTemporary ) _pSelected = _pTemporary;
 | 
        
           |  |  | 130 | 		_pTemporary = NULL;
 | 
        
           |  |  | 131 | 	}
 | 
        
           |  |  | 132 |   | 
        
           |  |  | 133 | 	void CGameDirectories::setLanguage(int iLang)
 | 
        
           |  |  | 134 | 	{
 | 
        
           |  |  | 135 | 		_iLanguage = iLang;
 | 
        
           |  |  | 136 | 	}
 | 
        
           |  |  | 137 |   | 
        
           |  |  | 138 | 	void CGameDirectories::setLoad(bool bLoad)
 | 
        
           |  |  | 139 | 	{
 | 
        
           |  |  | 140 | 		if ( _pCurrentItr ) _pCurrentItr->bLoad = bLoad;
 | 
        
           |  |  | 141 | 	}
 | 
        
           |  |  | 142 |   | 
        
           | 101 | cycrow | 143 | 	bool CGameDirectories::isAllTextLoaded() const
 | 
        
           |  |  | 144 | 	{
 | 
        
           |  |  | 145 | 		for ( std::vector<SGameDir *>::iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++ ) {
 | 
        
           |  |  | 146 | 			if ( !(*itr)->pVfs->isTextUpdated() ) return false;
 | 
        
           |  |  | 147 | 		}
 | 
        
           |  |  | 148 |   | 
        
           |  |  | 149 | 		return true;
 | 
        
           |  |  | 150 | 	}
 | 
        
           |  |  | 151 |   | 
        
           | 197 | cycrow | 152 | 	bool CGameDirectories::isDir(const Utils::WString &dir) const
 | 
        
           | 94 | cycrow | 153 | 	{
 | 
        
           |  |  | 154 | 		for ( std::vector<SGameDir *>::iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++ ) {
 | 
        
           |  |  | 155 | 			if ( dir.Compare((*itr)->dir) ) return true;
 | 
        
           |  |  | 156 | 		}
 | 
        
           |  |  | 157 |   | 
        
           |  |  | 158 | 		return false;
 | 
        
           |  |  | 159 | 	}
 | 
        
           |  |  | 160 |   | 
        
           |  |  | 161 | 	bool CGameDirectories::hasSelected() const
 | 
        
           |  |  | 162 | 	{
 | 
        
           |  |  | 163 | 		return (_pSelected) ? true : false;
 | 
        
           |  |  | 164 | 	}
 | 
        
           |  |  | 165 |   | 
        
           |  |  | 166 | 	bool CGameDirectories::isEmpty() const
 | 
        
           |  |  | 167 | 	{
 | 
        
           |  |  | 168 | 		return _pDirs->empty();
 | 
        
           |  |  | 169 | 	}
 | 
        
           |  |  | 170 |   | 
        
           |  |  | 171 | 	int CGameDirectories::highestGame() const
 | 
        
           |  |  | 172 | 	{
 | 
        
           |  |  | 173 | 		int highest = 1;
 | 
        
           |  |  | 174 | 		for(std::vector<SGameDir *>::const_iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++) {
 | 
        
           |  |  | 175 | 			if ( (*itr)->iGame > highest )
 | 
        
           |  |  | 176 | 				highest = (*itr)->iGame;
 | 
        
           |  |  | 177 | 		}
 | 
        
           |  |  | 178 |   | 
        
           |  |  | 179 | 		return highest;
 | 
        
           |  |  | 180 | 	}
 | 
        
           |  |  | 181 |   | 
        
           | 197 | cycrow | 182 | 	Utils::WString CGameDirectories::currentName() const
 | 
        
           | 94 | cycrow | 183 | 	{
 | 
        
           | 197 | cycrow | 184 | 		if ( !_pCurrentItr ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 185 | 		return _pCurrentItr->name;
 | 
        
           |  |  | 186 | 	}
 | 
        
           |  |  | 187 |   | 
        
           |  |  | 188 | 	int CGameDirectories::currentGame() const
 | 
        
           |  |  | 189 | 	{
 | 
        
           |  |  | 190 | 		if ( !_pCurrentItr ) return -1;
 | 
        
           |  |  | 191 | 		return _pCurrentItr->iGame;
 | 
        
           |  |  | 192 | 	}
 | 
        
           |  |  | 193 |   | 
        
           |  |  | 194 | 	bool CGameDirectories::currentLoad() const
 | 
        
           |  |  | 195 | 	{
 | 
        
           |  |  | 196 | 		if ( !_pCurrentItr ) return false;
 | 
        
           |  |  | 197 | 		return _pCurrentItr->bLoad;
 | 
        
           |  |  | 198 | 	}
 | 
        
           |  |  | 199 |   | 
        
           |  |  | 200 | 	CVirtualFileSystem *CGameDirectories::selectedVFS() const
 | 
        
           |  |  | 201 | 	{
 | 
        
           |  |  | 202 | 		if ( _pSelected ) return _pSelected->pVfs;
 | 
        
           |  |  | 203 | 		return NULL;
 | 
        
           |  |  | 204 | 	}
 | 
        
           |  |  | 205 |   | 
        
           | 95 | cycrow | 206 | 	void CGameDirectories::syncWithControlled(CGameExe *exe)
 | 
        
           |  |  | 207 | 	{
 | 
        
           | 197 | cycrow | 208 | 		for(Utils::WStringListIterator itr = _lControlledDirs.begin(); itr != _lControlledDirs.end(); itr++) {
 | 
        
           |  |  | 209 | 			add(exe->properDir((*itr)->str), (*itr)->data, exe->getGameType((*itr)->str), exe->addonDir((*itr)->str), true);
 | 
        
           | 95 | cycrow | 210 | 		}
 | 
        
           |  |  | 211 | 	}
 | 
        
           |  |  | 212 |   | 
        
           | 197 | cycrow | 213 | 	Utils::WString CGameDirectories::findText(int iLanguage, int iPage, int iID, Utils::WString missing)
 | 
        
           | 94 | cycrow | 214 | 	{
 | 
        
           |  |  | 215 | 		if ( iLanguage == 0 ) iLanguage = _iLanguage;
 | 
        
           |  |  | 216 | 		if ( _pSelected ) {
 | 
        
           |  |  | 217 | 			if ( _pSelected->pVfs->textExists(iLanguage, iPage, iID) ) {
 | 
        
           |  |  | 218 | 				return _pSelected->pVfs->findText(iLanguage, iPage, iID);
 | 
        
           |  |  | 219 | 			}
 | 
        
           |  |  | 220 | 		}
 | 
        
           |  |  | 221 |   | 
        
           |  |  | 222 | 		return missing;
 | 
        
           |  |  | 223 | 	}
 | 
        
           |  |  | 224 |   | 
        
           | 197 | cycrow | 225 | 	Utils::WString CGameDirectories::findText(int iGame, int iLanguage, int iPage, int iID)
 | 
        
           | 94 | cycrow | 226 | 	{
 | 
        
           |  |  | 227 | 		if ( iLanguage == 0 ) iLanguage = _iLanguage;
 | 
        
           |  |  | 228 | 		if ( iGame == -1 ) {
 | 
        
           |  |  | 229 | 			for ( int game = (GAME_MAX - 1); game >= 0; game-- ) {
 | 
        
           |  |  | 230 | 				SGameDir *gd = _findGameDir(game - 1);
 | 
        
           |  |  | 231 | 				if ( !gd ) continue;
 | 
        
           |  |  | 232 | 				if ( gd->pVfs->textExists(iLanguage, iPage, iID) ) {
 | 
        
           |  |  | 233 | 					return gd->pVfs->findText(iLanguage, iPage, iID);
 | 
        
           |  |  | 234 | 				}
 | 
        
           |  |  | 235 | 			}
 | 
        
           |  |  | 236 | 		}
 | 
        
           |  |  | 237 | 		else {
 | 
        
           |  |  | 238 | 			SGameDir *gd = _findGameDir(iGame);
 | 
        
           |  |  | 239 | 			if ( gd ) {
 | 
        
           |  |  | 240 | 				if ( gd->pVfs->textExists(iLanguage, iPage, iID) ) {
 | 
        
           |  |  | 241 | 					return gd->pVfs->findText(iLanguage, iPage, iID);
 | 
        
           |  |  | 242 | 				}
 | 
        
           |  |  | 243 | 			}
 | 
        
           |  |  | 244 | 		}
 | 
        
           |  |  | 245 |   | 
        
           | 197 | cycrow | 246 | 		return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 247 | 	}
 | 
        
           |  |  | 248 |   | 
        
           | 197 | cycrow | 249 | 	Utils::WString CGameDirectories::first(int iGame)
 | 
        
           | 94 | cycrow | 250 | 	{
 | 
        
           | 197 | cycrow | 251 | 		if ( _pDirs->empty() ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 252 |   | 
        
           |  |  | 253 | 		_pCurrentItr = *_pDirs->begin();
 | 
        
           |  |  | 254 | 		if ( iGame > -1 && _pCurrentItr->iGame != iGame ) return next(iGame);
 | 
        
           | 197 | cycrow | 255 | 		return (_pCurrentItr) ? _pCurrentItr->dir : Utils::WString::Null();
 | 
        
           | 94 | cycrow | 256 | 	}
 | 
        
           |  |  | 257 |   | 
        
           | 197 | cycrow | 258 | 	Utils::WString CGameDirectories::next(int iGame)
 | 
        
           | 94 | cycrow | 259 | 	{
 | 
        
           | 197 | cycrow | 260 | 		if ( !_pCurrentItr ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 261 |   | 
        
           |  |  | 262 | 		bool found = false;
 | 
        
           |  |  | 263 | 		for(std::vector<SGameDir *>::iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++) {
 | 
        
           |  |  | 264 | 			if ( (*itr) == _pCurrentItr ) found = true;
 | 
        
           |  |  | 265 | 			else if ( found && ((*itr)->iGame == iGame || iGame == -1) ) {
 | 
        
           |  |  | 266 | 				_pCurrentItr = *(itr);
 | 
        
           | 197 | cycrow | 267 | 				return (_pCurrentItr) ? _pCurrentItr->dir : Utils::WString::Null();
 | 
        
           | 94 | cycrow | 268 | 			}
 | 
        
           |  |  | 269 | 		}
 | 
        
           |  |  | 270 |   | 
        
           | 197 | cycrow | 271 | 		return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 272 | 	}
 | 
        
           |  |  | 273 |   | 
        
           | 197 | cycrow | 274 | 	Utils::WString CGameDirectories::firstShield()
 | 
        
           | 94 | cycrow | 275 | 	{
 | 
        
           | 197 | cycrow | 276 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 277 | 		return _pSelected->pVfs->firstShield();
 | 
        
           |  |  | 278 | 	}
 | 
        
           |  |  | 279 |   | 
        
           | 197 | cycrow | 280 | 	Utils::WString CGameDirectories::nextShield()
 | 
        
           | 94 | cycrow | 281 | 	{
 | 
        
           | 197 | cycrow | 282 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 283 | 		return _pSelected->pVfs->nextShield();
 | 
        
           |  |  | 284 | 	}
 | 
        
           |  |  | 285 |   | 
        
           | 197 | cycrow | 286 | 	Utils::WString CGameDirectories::firstComponentSection()
 | 
        
           | 94 | cycrow | 287 | 	{
 | 
        
           | 197 | cycrow | 288 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 289 | 		return _pSelected->pVfs->firstComponentSection();
 | 
        
           |  |  | 290 | 	}
 | 
        
           |  |  | 291 |   | 
        
           | 197 | cycrow | 292 | 	Utils::WString CGameDirectories::nextComponentSection()
 | 
        
           | 94 | cycrow | 293 | 	{
 | 
        
           | 197 | cycrow | 294 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 295 | 		return _pSelected->pVfs->nextComponentSection();
 | 
        
           |  |  | 296 | 	}
 | 
        
           |  |  | 297 |   | 
        
           | 197 | cycrow | 298 | 	Utils::WString CGameDirectories::firstDummySection()
 | 
        
           | 94 | cycrow | 299 | 	{
 | 
        
           | 197 | cycrow | 300 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 301 | 		return _pSelected->pVfs->firstDummySection();
 | 
        
           |  |  | 302 | 	}
 | 
        
           |  |  | 303 |   | 
        
           | 197 | cycrow | 304 | 	Utils::WString CGameDirectories::nextDummySection()
 | 
        
           | 94 | cycrow | 305 | 	{
 | 
        
           | 197 | cycrow | 306 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 307 | 		return _pSelected->pVfs->nextDummySection();
 | 
        
           |  |  | 308 | 	}
 | 
        
           |  |  | 309 |   | 
        
           | 197 | cycrow | 310 | 	Utils::WString CGameDirectories::firstBodiesSection()
 | 
        
           | 94 | cycrow | 311 | 	{
 | 
        
           | 197 | cycrow | 312 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 313 | 		return _pSelected->pVfs->firstBodiesSection();
 | 
        
           |  |  | 314 | 	}
 | 
        
           |  |  | 315 |   | 
        
           | 197 | cycrow | 316 | 	Utils::WString CGameDirectories::nextBodiesSection()
 | 
        
           | 94 | cycrow | 317 | 	{
 | 
        
           | 197 | cycrow | 318 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 319 | 		return _pSelected->pVfs->nextBodiesSection();
 | 
        
           |  |  | 320 | 	}
 | 
        
           |  |  | 321 |   | 
        
           | 197 | cycrow | 322 | 	Utils::WString CGameDirectories::firstCockpit()
 | 
        
           | 94 | cycrow | 323 | 	{
 | 
        
           | 197 | cycrow | 324 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 325 | 		return _pSelected->pVfs->firstCockpit();
 | 
        
           |  |  | 326 | 	}
 | 
        
           |  |  | 327 |   | 
        
           | 197 | cycrow | 328 | 	Utils::WString CGameDirectories::nextCockpit()
 | 
        
           | 94 | cycrow | 329 | 	{
 | 
        
           | 197 | cycrow | 330 | 		if ( !_pSelected ) return Utils::WString::Null();
 | 
        
           | 94 | cycrow | 331 | 		return _pSelected->pVfs->nextCockpit();
 | 
        
           |  |  | 332 | 	}
 | 
        
           |  |  | 333 |   | 
        
           | 197 | cycrow | 334 | 	std::pair<Utils::WString, Utils::WString> CGameDirectories::firstLaser() const
 | 
        
           | 94 | cycrow | 335 | 	{
 | 
        
           | 197 | cycrow | 336 | 		if ( !_pSelected ) return std::make_pair<Utils::WString, Utils::WString>(Utils::WString::Null(), Utils::WString::Null());
 | 
        
           | 94 | cycrow | 337 | 		return _pSelected->pVfs->firstLaser();
 | 
        
           |  |  | 338 | 	}
 | 
        
           |  |  | 339 |   | 
        
           | 197 | cycrow | 340 | 	std::pair<Utils::WString, Utils::WString> CGameDirectories::nextLaser() const
 | 
        
           | 94 | cycrow | 341 | 	{
 | 
        
           | 197 | cycrow | 342 | 		if ( !_pSelected ) return std::make_pair<Utils::WString, Utils::WString>(Utils::WString::Null(), Utils::WString::Null());
 | 
        
           | 94 | cycrow | 343 | 		return _pSelected->pVfs->nextLaser();
 | 
        
           |  |  | 344 | 	}
 | 
        
           |  |  | 345 |   | 
        
           | 197 | cycrow | 346 | 	std::pair<Utils::WString, Utils::WString> CGameDirectories::firstMissile() const
 | 
        
           | 94 | cycrow | 347 | 	{
 | 
        
           | 197 | cycrow | 348 | 		if ( !_pSelected ) return std::make_pair<Utils::WString, Utils::WString>(Utils::WString::Null(), Utils::WString::Null());
 | 
        
           | 94 | cycrow | 349 | 		return _pSelected->pVfs->firstMissile();
 | 
        
           |  |  | 350 | 	}
 | 
        
           |  |  | 351 |   | 
        
           | 197 | cycrow | 352 | 	std::pair<Utils::WString, Utils::WString> CGameDirectories::nextMissile() const
 | 
        
           | 94 | cycrow | 353 | 	{
 | 
        
           | 197 | cycrow | 354 | 		if ( !_pSelected ) return std::make_pair<Utils::WString, Utils::WString>(Utils::WString::Null(), Utils::WString::Null());
 | 
        
           | 94 | cycrow | 355 | 		return _pSelected->pVfs->nextMissile();
 | 
        
           |  |  | 356 | 	}
 | 
        
           |  |  | 357 |   | 
        
           |  |  | 358 | 	SGameDir *CGameDirectories::_findGameDir(int iGame) const
 | 
        
           |  |  | 359 | 	{
 | 
        
           |  |  | 360 | 		if ( iGame == -1 ) {
 | 
        
           |  |  | 361 | 			for ( int game = (GAME_MAX - 1); game >= 0; game-- ) {
 | 
        
           |  |  | 362 | 				SGameDir *gd = _findGameDir(game);
 | 
        
           |  |  | 363 | 				if ( !gd ) continue;
 | 
        
           |  |  | 364 | 				return gd;
 | 
        
           |  |  | 365 | 			}
 | 
        
           |  |  | 366 | 		}
 | 
        
           |  |  | 367 | 		else {
 | 
        
           |  |  | 368 | 			for(std::vector<SGameDir *>::const_iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++) {
 | 
        
           |  |  | 369 | 				if ( (*itr)->iGame == iGame ) return *itr;
 | 
        
           |  |  | 370 | 			}
 | 
        
           |  |  | 371 | 		}
 | 
        
           |  |  | 372 | 		return NULL;
 | 
        
           |  |  | 373 | 	}
 | 
        
           |  |  | 374 |   | 
        
           | 197 | cycrow | 375 | 	SGameDir *CGameDirectories::_findGameDir(const Utils::WString &dir) const
 | 
        
           | 94 | cycrow | 376 | 	{
 | 
        
           |  |  | 377 | 		for(std::vector<SGameDir *>::const_iterator itr = _pDirs->begin(); itr != _pDirs->end(); itr++) {
 | 
        
           |  |  | 378 | 			if ( (*itr)->dir.Compare(dir) )
 | 
        
           |  |  | 379 | 				return *itr;
 | 
        
           |  |  | 380 | 		}
 | 
        
           |  |  | 381 |   | 
        
           |  |  | 382 | 		return NULL;
 | 
        
           |  |  | 383 | 	}
 | 
        
           |  |  | 384 |   | 
        
           | 197 | cycrow | 385 | 	void CGameDirectories::_add(const Utils::WString &dir, const Utils::WString &name, int iGame, const Utils::WString &addon, bool bLoad)
 | 
        
           | 94 | cycrow | 386 | 	{
 | 
        
           |  |  | 387 | 		SGameDir *gd = new SGameDir;
 | 
        
           |  |  | 388 |   | 
        
           |  |  | 389 | 		gd->dir = dir;
 | 
        
           |  |  | 390 | 		gd->name = name;
 | 
        
           |  |  | 391 | 		gd->iGame = iGame;
 | 
        
           |  |  | 392 |   | 
        
           |  |  | 393 | 		gd->bLoad = bLoad;
 | 
        
           |  |  | 394 | 		gd->pVfs = new CVirtualFileSystem();
 | 
        
           |  |  | 395 | 		gd->pVfs->setLanguage(44);
 | 
        
           | 114 | cycrow | 396 | 		gd->pVfs->setAddon(addon);
 | 
        
           | 94 | cycrow | 397 | 		gd->pVfs->LoadFilesystem(gd->dir);
 | 
        
           |  |  | 398 |   | 
        
           |  |  | 399 | 		_pDirs->push_back(gd);
 | 
        
           |  |  | 400 | 	}
 | 
        
           | 95 | cycrow | 401 |   | 
        
           | 197 | cycrow | 402 | 	void CGameDirectories::_updateControlledDirs(const Utils::WString &mydoc)
 | 
        
           | 95 | cycrow | 403 | 	{
 | 
        
           | 112 | cycrow | 404 | 		_lControlledDirs.clear();
 | 
        
           | 95 | cycrow | 405 |   | 
        
           | 197 | cycrow | 406 | 		CFileIO configFile(mydoc + L"/Egosoft/pluginmanager.dat");
 | 
        
           | 95 | cycrow | 407 | 		if ( configFile.startRead() ) {
 | 
        
           |  |  | 408 | 			while(!configFile.atEnd()) {
 | 
        
           | 197 | cycrow | 409 | 				Utils::WString line = configFile.readEndOfLine();
 | 
        
           |  |  | 410 | 				if ( line.token(L":", 1).Compare(L"DirExe") ) {
 | 
        
           | 230 | cycrow | 411 | 					Utils::WString rest = line.tokens(L":", 2).removeFirstSpace().remove('\r').remove('\n');
 | 
        
           | 197 | cycrow | 412 | 					if ( rest.countToken(L"|" ) > 2 )
 | 
        
           |  |  | 413 | 						_lControlledDirs.pushBack(rest.token(L"|", 3), rest.token(L"|", 2));
 | 
        
           | 95 | cycrow | 414 | 					else
 | 
        
           | 197 | cycrow | 415 | 						_lControlledDirs.pushBack(rest.token(L"|", 2), rest.token(L"|", 1));
 | 
        
           | 95 | cycrow | 416 | 				}
 | 
        
           |  |  | 417 | 			}
 | 
        
           |  |  | 418 | 		}
 | 
        
           |  |  | 419 | 	}
 | 
        
           | 94 | cycrow | 420 | }
 |