| 1 | cycrow | 1 | #pragma once
 | 
        
           |  |  | 2 |   | 
        
           |  |  | 3 | #include "File.h"
 | 
        
           | 197 | cycrow | 4 | #include "Utils/WString.h"
 | 
        
           | 1 | cycrow | 5 | #include <map>
 | 
        
           |  |  | 6 |   | 
        
           | 35 | cycrow | 7 | class CBaseFile;
 | 
        
           |  |  | 8 | class CXspFile;
 | 
        
           |  |  | 9 |   | 
        
           | 94 | cycrow | 10 | namespace Utils {
 | 
        
           | 197 | cycrow | 11 | 	class WStringList;
 | 
        
           | 94 | cycrow | 12 | }
 | 
        
           | 35 | cycrow | 13 | namespace SPK {
 | 
        
           | 94 | cycrow | 14 | 	class CTextDB;
 | 
        
           | 35 | cycrow | 15 |   | 
        
           | 1 | cycrow | 16 | tclass CVirtualFileSystem
 | 
        
           |  |  | 17 | {
 | 
        
           |  |  | 18 | public:
 | 
        
           | 197 | cycrow | 19 | 	typedef std::map<Utils::WString, Utils::WString> FileList;
 | 
        
           |  |  | 20 | 	typedef std::map<Utils::WString, Utils::WString>::iterator FileListItr;
 | 
        
           | 35 | cycrow | 21 |   | 
        
           |  |  | 22 | private:
 | 
        
           | 197 | cycrow | 23 | 	Utils::WString	m_sAddon;
 | 
        
           |  |  | 24 | 	Utils::WString	m_sDir;
 | 
        
           | 35 | cycrow | 25 | 	bool		m_bLoaded;
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 | 	FileList *m_pModMap;
 | 
        
           |  |  | 28 | 	FileList *m_pMap;
 | 
        
           |  |  | 29 |   | 
        
           |  |  | 30 | 	CTextDB	 *m_pTexts;
 | 
        
           |  |  | 31 | 	CTextDB  *m_pModTexts;
 | 
        
           |  |  | 32 |   | 
        
           | 197 | cycrow | 33 | 	Utils::WStringList	*_lShips;
 | 
        
           |  |  | 34 | 	Utils::WStringList	*_lShields;
 | 
        
           |  |  | 35 | 	Utils::WStringList	*_lLasers;
 | 
        
           |  |  | 36 | 	Utils::WStringList	*_lMissiles;
 | 
        
           |  |  | 37 | 	Utils::WStringList	*_lCockpits;
 | 
        
           |  |  | 38 | 	Utils::WStringList	*_lComponentSections;
 | 
        
           |  |  | 39 | 	Utils::WStringList	*_lDummySections;
 | 
        
           |  |  | 40 | 	Utils::WStringList	*_lBodiesSections;
 | 
        
           | 94 | cycrow | 41 |   | 
        
           | 35 | cycrow | 42 | 	int m_iLang;
 | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 | public:
 | 
        
           | 1 | cycrow | 45 | 	CVirtualFileSystem(void);
 | 
        
           |  |  | 46 | 	~CVirtualFileSystem(void);
 | 
        
           |  |  | 47 |   | 
        
           | 101 | cycrow | 48 | 	// setters
 | 
        
           | 197 | cycrow | 49 | 	void setAddon(const Utils::WString &addon);
 | 
        
           | 101 | cycrow | 50 | 	void setLanguage(int iLang);
 | 
        
           | 1 | cycrow | 51 |   | 
        
           | 101 | cycrow | 52 | 	// extractions
 | 
        
           | 35 | cycrow | 53 | 	void extractTexts(CXspFile *pPackage, int textId);
 | 
        
           | 197 | cycrow | 54 | 	C_File *extractGameFileToPackage(CBaseFile *pPackage, const Utils::WString &sFile, FileType iFileType, const Utils::WString &sTo);
 | 
        
           |  |  | 55 | 	C_File *extractGameFileToPackage(CBaseFile *pPackage, const Utils::WString &sFile, FileType iFileType);
 | 
        
           |  |  | 56 | 	Utils::WString extractGameFile(const Utils::WString &file, const Utils::WString &to);
 | 
        
           | 101 | cycrow | 57 |   | 
        
           |  |  | 58 | 	// loading
 | 
        
           | 197 | cycrow | 59 | 	bool LoadFilesystem(const Utils::WString &dir, int maxPatch = 0);
 | 
        
           |  |  | 60 | 	bool LoadFilesystem(const Utils::WString &dir, const Utils::WString &mod, int maxPatch = 0);
 | 
        
           |  |  | 61 | 	bool loadMod(const Utils::WString &mod);
 | 
        
           |  |  | 62 | 	bool addMod(const Utils::WString &mod);
 | 
        
           | 101 | cycrow | 63 |   | 
        
           |  |  | 64 | 	// getters
 | 
        
           | 197 | cycrow | 65 | 	const Utils::WString &directory() const;
 | 
        
           |  |  | 66 | 	bool isFileAvailable(const Utils::WString &file) const;
 | 
        
           |  |  | 67 | 	Utils::WString getTShipsEntry(const Utils::WString &sId);
 | 
        
           |  |  | 68 | 	Utils::WString findText(int iLang, int iPage, int iID) const;
 | 
        
           | 101 | cycrow | 69 | 	bool textExists(int iLang, int iPage, int iID) const;
 | 
        
           |  |  | 70 | 	bool isTextUpdated() const;
 | 
        
           | 35 | cycrow | 71 |   | 
        
           | 101 | cycrow | 72 | 	// Updates
 | 
        
           | 35 | cycrow | 73 | 	void updateModTexts(int iPage);
 | 
        
           |  |  | 74 | 	void updateModTexts(int iFromPage, int iToPage);
 | 
        
           |  |  | 75 | 	void updateTexts(int iPage);
 | 
        
           |  |  | 76 | 	void updateTexts(int iFromPage, int iToPage);
 | 
        
           |  |  | 77 |   | 
        
           | 78 | cycrow | 78 | 	void clearMods(bool bIncludeStandard = false);
 | 
        
           | 35 | cycrow | 79 |   | 
        
           | 101 | cycrow | 80 | 	// Iterators
 | 
        
           | 197 | cycrow | 81 | 	Utils::WStringList *getTShipsEntries();
 | 
        
           |  |  | 82 | 	Utils::WString firstShield();
 | 
        
           |  |  | 83 | 	Utils::WString nextShield();
 | 
        
           |  |  | 84 | 	Utils::WString firstComponentSection();
 | 
        
           |  |  | 85 | 	Utils::WString nextComponentSection();
 | 
        
           |  |  | 86 | 	Utils::WString firstDummySection();
 | 
        
           |  |  | 87 | 	Utils::WString nextDummySection();
 | 
        
           |  |  | 88 | 	Utils::WString firstBodiesSection();
 | 
        
           |  |  | 89 | 	Utils::WString nextBodiesSection();
 | 
        
           |  |  | 90 | 	std::pair<Utils::WString, Utils::WString> firstLaser();
 | 
        
           |  |  | 91 | 	std::pair<Utils::WString, Utils::WString> nextLaser();
 | 
        
           |  |  | 92 | 	std::pair<Utils::WString, Utils::WString> firstMissile();
 | 
        
           |  |  | 93 | 	std::pair<Utils::WString, Utils::WString> nextMissile();
 | 
        
           |  |  | 94 | 	Utils::WString firstCockpit();
 | 
        
           |  |  | 95 | 	Utils::WString nextCockpit();
 | 
        
           | 94 | cycrow | 96 |   | 
        
           | 114 | cycrow | 97 | 	///////////////////////////////////////////////////////////////
 | 
        
           |  |  | 98 | 	// Debug Functions
 | 
        
           | 197 | cycrow | 99 | 	void DEBUG_LogContents(const Utils::WString &sFile);	
 | 
        
           | 114 | cycrow | 100 |   | 
        
           | 1 | cycrow | 101 | private:
 | 
        
           | 35 | cycrow | 102 | 	void _updateTexts(int iFromPage, int iToPage, FileList *pFileList, CTextDB *pTextList);
 | 
        
           | 197 | cycrow | 103 | 	Utils::WString _convertExtension(const Utils::WString &sFile) const;
 | 
        
           | 35 | cycrow | 104 | 	void _clear();
 | 
        
           | 197 | cycrow | 105 | 	void _addFile(const Utils::WString &sFile, const Utils::WString &sDest, FileList *pList);
 | 
        
           |  |  | 106 | 	void _addModFile(const Utils::WString &sFile, const Utils::WString &sMod, FileList *pList);
 | 
        
           |  |  | 107 | 	Utils::WString _findFile(const Utils::WString &file) const;
 | 
        
           |  |  | 108 | 	void _addDir(const Utils::WString &sStart, const Utils::WString &sDir);
 | 
        
           |  |  | 109 | 	Utils::WString _extractFromCat(const Utils::WString &sCat, const Utils::WString &sFile, const Utils::WString &sTo);
 | 
        
           |  |  | 110 | 	Utils::WString _extract(const Utils::WString &sFile, const Utils::WString &sTo);
 | 
        
           | 94 | cycrow | 111 |   | 
        
           | 197 | cycrow | 112 | 	Utils::WStringList *_updateList(const Utils::WString &typesFile, int iTextPos);
 | 
        
           | 94 | cycrow | 113 | 	void _updateShields();
 | 
        
           |  |  | 114 | 	void _updateLasers();
 | 
        
           |  |  | 115 | 	void _updateMissiles();
 | 
        
           |  |  | 116 | 	void _updateCockpits();
 | 
        
           |  |  | 117 | 	void _updateComponentSections();
 | 
        
           |  |  | 118 | 	void _updateDummySections();
 | 
        
           |  |  | 119 | 	void _updateBodiesSections();
 | 
        
           | 101 | cycrow | 120 | 	void _updateShips();
 | 
        
           | 94 | cycrow | 121 |   | 
        
           | 197 | cycrow | 122 | 	Utils::WString _returnText(Utils::WStringNode *s);
 | 
        
           |  |  | 123 | 	Utils::WString _returnID(Utils::WStringNode *s);
 | 
        
           |  |  | 124 | 	Utils::WString _returnLine(Utils::WStringNode *s);
 | 
        
           |  |  | 125 | 	std::pair<Utils::WString, Utils::WString> _returnPair(Utils::WStringNode *s);
 | 
        
           |  |  | 126 | 	Utils::WStringList *_updateSectionList(const Utils::WString &sFile, bool singleEntry);
 | 
        
           | 114 | cycrow | 127 |   | 
        
           | 197 | cycrow | 128 | 	void _removeSameFile(const Utils::WString &sFile, const Utils::WString &sDest, const Utils::WString &ext, FileList *pList);
 | 
        
           | 114 | cycrow | 129 |   | 
        
           | 35 | cycrow | 130 | };
 | 
        
           | 1 | cycrow | 131 |   | 
        
           | 35 | cycrow | 132 | }
 |