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