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