| 1 | cycrow | 1 | #pragma once
 | 
        
           | 6 | cycrow | 2 | #include "BaseFile.h"
 | 
        
           | 94 | cycrow | 3 | #include "spkdefines.h"
 | 
        
           | 1 | cycrow | 4 |   | 
        
           | 6 | cycrow | 5 | class SPKEXPORT CSpkFile : public CBaseFile
 | 
        
           | 1 | cycrow | 6 | {
 | 
        
           |  |  | 7 | public:
 | 
        
           | 6 | cycrow | 8 | 	enum {
 | 
        
           |  |  | 9 | 		SCRIPTTYPE_CUSTOM,
 | 
        
           |  |  | 10 | 		SCRIPTTYPE_OTHER,
 | 
        
           |  |  | 11 | 		SCRIPTTYPE_NAVIGATION,
 | 
        
           |  |  | 12 | 		SCRIPTTYPE_COMBAT,
 | 
        
           |  |  | 13 | 		SCRIPTTYPE_MISSION,
 | 
        
           |  |  | 14 | 		SCRIPTTYPE_ALPLUGIN,
 | 
        
           |  |  | 15 | 		SCRIPTTYPE_HOTKEY,
 | 
        
           |  |  | 16 | 		SCRIPTTYPE_SHIPUPGRADE,
 | 
        
           |  |  | 17 | 		SCRIPTTYPE_SHIPCOMMAND,
 | 
        
           |  |  | 18 | 		SCRIPTTYPE_STATIONCOMMAND,
 | 
        
           |  |  | 19 | 		SCRIPTTYPE_FLEET,
 | 
        
           |  |  | 20 | 		SCRIPTTYPE_TRADE,
 | 
        
           |  |  | 21 | 		SCRIPTTYPE_PIRACY,
 | 
        
           |  |  | 22 | 		SCRIPTTYPE_CHEAT,
 | 
        
           |  |  | 23 | 		SCRIPTTYPE_EXTENSION,
 | 
        
           |  |  | 24 | 		SCRIPTTYPE_REBALANCE,
 | 
        
           |  |  | 25 | 		SCRIPTTYPE_FIX,
 | 
        
           |  |  | 26 | 		SCRIPTTYPE_GENERALMOD,
 | 
        
           |  |  | 27 | 		SCRIPTTYPE_TOTAL,
 | 
        
           |  |  | 28 | 		SCRIPTTYPE_WINGCOMMAND,
 | 
        
           |  |  | 29 | 		SCRIPTTYPE_MAX
 | 
        
           |  |  | 30 | 	};
 | 
        
           | 1 | cycrow | 31 |   | 
        
           | 6 | cycrow | 32 | private:
 | 
        
           |  |  | 33 | 	enum {
 | 
        
           |  |  | 34 | 		SETTING_INTEGER,
 | 
        
           |  |  | 35 | 		SETTING_STRING,
 | 
        
           |  |  | 36 | 		SETTING_CHECK
 | 
        
           |  |  | 37 | 	};
 | 
        
           | 1 | cycrow | 38 |   | 
        
           | 6 | cycrow | 39 | 	typedef struct SSettingString : public SSettingType {
 | 
        
           |  |  | 40 | 		SSettingString () { iType = SETTING_STRING; }
 | 
        
           | 10 | cycrow | 41 | 		Utils::String sValue;
 | 
        
           | 6 | cycrow | 42 | 	} SSettingString;
 | 
        
           | 1 | cycrow | 43 |   | 
        
           | 6 | cycrow | 44 | 	typedef struct SSettingInteger : public SSettingType {
 | 
        
           |  |  | 45 | 		SSettingInteger () { iType = SETTING_INTEGER; }
 | 
        
           |  |  | 46 | 		int iValue;
 | 
        
           |  |  | 47 | 	} SSettingInteger;
 | 
        
           | 1 | cycrow | 48 |   | 
        
           | 6 | cycrow | 49 | 	typedef struct SSettingCheck : public SSettingType {
 | 
        
           |  |  | 50 | 		SSettingCheck () { iType = SETTING_CHECK; }
 | 
        
           |  |  | 51 | 		bool bValue ;
 | 
        
           |  |  | 52 | 	} SSettingCheck;
 | 
        
           | 1 | cycrow | 53 |   | 
        
           | 13 | cycrow | 54 |   | 
        
           | 1 | cycrow | 55 | public:
 | 
        
           | 10 | cycrow | 56 | 	static int ConvertScriptType(const Utils::String &sType);
 | 
        
           |  |  | 57 | 	static Utils::String GetScriptTypeStringStatic(int type);
 | 
        
           | 197 | cycrow | 58 | 	static Utils::WString GetWareText(SWares *w, int lang);
 | 
        
           |  |  | 59 | 	static Utils::WString GetWareDesc(SWares *w, int lang);
 | 
        
           | 1 | cycrow | 60 |   | 
        
           |  |  | 61 | 	// get functions
 | 
        
           | 13 | cycrow | 62 | 	Utils::String GetScriptTypeString(int lang) const;
 | 
        
           |  |  | 63 | 	Utils::String GetCustomScriptType () const { return m_sScriptType; }
 | 
        
           |  |  | 64 | 	Utils::String GetCustomScriptType (int lang) const;
 | 
        
           | 133 | cycrow | 65 | 	Utils::String otherName() const { return m_sOtherName; }
 | 
        
           |  |  | 66 | 	Utils::String otherAuthor()	const { return m_sOtherAuthor; }
 | 
        
           |  |  | 67 | 	Utils::String GetOtherName() const { return m_sOtherName; }
 | 
        
           |  |  | 68 | 	Utils::String GetOtherAuthor()	const { return m_sOtherAuthor; }
 | 
        
           | 1 | cycrow | 69 | 	CLinkList<SWares> *GetWaresList() { return &m_lWares; }
 | 
        
           |  |  | 70 | 	CLinkList<SSettingType> *GetSettingsList() { return &m_lSettings; }
 | 
        
           |  |  | 71 |   | 
        
           | 13 | cycrow | 72 | 	bool CheckValidReadmes () const;
 | 
        
           | 1 | cycrow | 73 |   | 
        
           | 13 | cycrow | 74 | 	bool   IsCustomStart () const	{ return (m_iPackageType == PACKAGETYPE_CUSTOMSTART) ? true : false;  }
 | 
        
           |  |  | 75 | 	bool   IsPackageUpdate () const { return (m_iPackageType == PACKAGETYPE_UPDATE) ? true : false; }
 | 
        
           |  |  | 76 | 	bool   IsPatch () const			{ return (m_iPackageType == PACKAGETYPE_PATCH) ? true: false; }
 | 
        
           |  |  | 77 | 	bool   IsLibrary ()	const		{ return (m_iPackageType == PACKAGETYPE_LIBRARY) ? true: false; }
 | 
        
           | 133 | cycrow | 78 | 	bool   IsAnotherMod() const { if ((m_sOtherName.empty()) || (m_sOtherAuthor.empty())) return false; return true; }
 | 
        
           |  |  | 79 | 	bool   isAnotherMod() const { if ((m_sOtherName.empty()) || (m_sOtherAuthor.empty())) return false; return true; }
 | 
        
           | 13 | cycrow | 80 | 	bool   IsForceProfile() const	{ return m_bForceProfile; }
 | 
        
           |  |  | 81 | 	int		GetScriptType() const	{ return m_iScriptType; }
 | 
        
           |  |  | 82 | 	int		GetPackageType() const	{ return m_iPackageType; }
 | 
        
           | 1 | cycrow | 83 |   | 
        
           | 88 | cycrow | 84 | 	virtual bool readWares(int iLang, CLinkList<SWareEntry> &list, const Utils::String &empWares);
 | 
        
           |  |  | 85 |   | 
        
           | 1 | cycrow | 86 | 	// Custom Start
 | 
        
           | 13 | cycrow | 87 | 	Utils::String GetCustomStartName() const;
 | 
        
           | 1 | cycrow | 88 |   | 
        
           |  |  | 89 | 	// set functions
 | 
        
           | 50 | cycrow | 90 | 	void SetScriptType	 ( const Utils::String &str ) { m_sScriptType = str; _changed(); }
 | 
        
           |  |  | 91 | 	void SetAnotherMod   ( const Utils::String &name, const Utils::String &author ) { m_sOtherName = name; m_sOtherAuthor = author; _changed(); }
 | 
        
           |  |  | 92 | 	void SetForceProfile ( bool p ) { m_bForceProfile = p; _changed(); }
 | 
        
           | 1 | cycrow | 93 |   | 
        
           |  |  | 94 | 	void SetPackageType(int i)
 | 
        
           |  |  | 95 | 	{
 | 
        
           |  |  | 96 | 		m_iPackageType = i;
 | 
        
           |  |  | 97 | 		if ( i == PACKAGETYPE_UPDATE )
 | 
        
           |  |  | 98 | 		{
 | 
        
           | 203 | cycrow | 99 | 			if ( !this->findPackageNeeded(L"<package>", L"<author>") )
 | 
        
           |  |  | 100 | 				this->addNeededLibrary(L"<package>", L"<author>", "1.00");
 | 
        
           | 1 | cycrow | 101 | 		}
 | 
        
           |  |  | 102 | 		else
 | 
        
           | 203 | cycrow | 103 | 			this->removePackageNeeded(L"<package>", L"<author>");
 | 
        
           | 50 | cycrow | 104 | 		_changed();
 | 
        
           | 1 | cycrow | 105 | 	}
 | 
        
           |  |  | 106 | 	void SetPatch() { this->SetPackageType(PACKAGETYPE_PATCH); }
 | 
        
           |  |  | 107 | 	void SetLibrary() { this->SetPackageType(PACKAGETYPE_LIBRARY); }
 | 
        
           |  |  | 108 | 	void SetCustomStart() { this->SetPackageType(PACKAGETYPE_CUSTOMSTART); }
 | 
        
           |  |  | 109 | 	void SetPackageUpdate() { this->SetPackageType(PACKAGETYPE_UPDATE); }
 | 
        
           |  |  | 110 | 	void SetNormalPackage() { this->SetPackageType(PACKAGETYPE_NORMAL); }
 | 
        
           | 50 | cycrow | 111 | 	void SetScriptType(int i) { SetNormalPackage(); m_iScriptType = i; _changed(); }
 | 
        
           | 1 | cycrow | 112 |   | 
        
           | 197 | cycrow | 113 | 	virtual bool loadPackageData(const Utils::WString &sFirst, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress = NULL) override;
 | 
        
           | 127 | cycrow | 114 | 	virtual bool GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons, bool datafile = false) override;
 | 
        
           | 1 | cycrow | 115 |   | 
        
           |  |  | 116 | 	CSpkFile();
 | 
        
           |  |  | 117 | 	virtual ~CSpkFile();
 | 
        
           |  |  | 118 |   | 
        
           | 13 | cycrow | 119 | 	bool IsMatchingMod(const Utils::String &mod) const;
 | 
        
           | 1 | cycrow | 120 |   | 
        
           |  |  | 121 | 	/// reading of files
 | 
        
           | 14 | cycrow | 122 | 	virtual bool ParseValueLine(const Utils::String &line);
 | 
        
           | 1 | cycrow | 123 |   | 
        
           |  |  | 124 | 	// writing of files
 | 
        
           | 175 | cycrow | 125 | 	virtual Utils::String createValuesLine() const override;
 | 
        
           |  |  | 126 | 	bool writeHeader(CFileIO &file, int iHeader, int iLength) const override;
 | 
        
           | 1 | cycrow | 127 |   | 
        
           | 10 | cycrow | 128 | 	SWares *FindWare(const Utils::String &id) const;
 | 
        
           |  |  | 129 | 	void AddWare(const Utils::String &sWareLine);
 | 
        
           | 197 | cycrow | 130 | 	void addWareText(const Utils::WString &sText);
 | 
        
           | 10 | cycrow | 131 | 	void AddWare(SWares *pWare);
 | 
        
           | 197 | cycrow | 132 | 	void addWareText(SWares *pWare, int iLang, const Utils::WString &sName, const Utils::WString &sDesc);
 | 
        
           | 10 | cycrow | 133 | 	void RemoveWare(const Utils::String &sWare);
 | 
        
           |  |  | 134 | 	void RemoveWareText(const Utils::String &sName, int iLang);
 | 
        
           |  |  | 135 | 	void ClearWareText(SWares *pWare);
 | 
        
           |  |  | 136 | 	void ClearWareText(const Utils::String &sWare);
 | 
        
           | 1 | cycrow | 137 | 	void ClearWares ();
 | 
        
           | 10 | cycrow | 138 | 	bool AnyWares() const { return !m_lWares.empty(); }
 | 
        
           | 1 | cycrow | 139 |   | 
        
           | 13 | cycrow | 140 | 	int CheckValidCustomStart () const;
 | 
        
           | 1 | cycrow | 141 |   | 
        
           | 175 | cycrow | 142 | 	virtual bool computeSigned(bool updateFiles) const override;
 | 
        
           | 1 | cycrow | 143 |   | 
        
           | 10 | cycrow | 144 | 	SSettingType *AddSetting(const Utils::String &key, int type);
 | 
        
           | 1 | cycrow | 145 | 	void ClearSettings ();
 | 
        
           | 10 | cycrow | 146 | 	void ConvertSetting ( SSettingType *t, const Utils::String &set ) const;
 | 
        
           |  |  | 147 | 	Utils::String GetSetting ( SSettingType *t ) const;
 | 
        
           |  |  | 148 | 	bool AnySettings() const { return !m_lSettings.empty(); }
 | 
        
           | 1 | cycrow | 149 |   | 
        
           |  |  | 150 | 	// installer usage
 | 
        
           | 10 | cycrow | 151 | 	Utils::String GetLastReadme () const { return m_sLastReadme; }
 | 
        
           |  |  | 152 | 	Utils::String GetCustomMap () const { return m_sCustomMap; }
 | 
        
           | 1 | cycrow | 153 |   | 
        
           | 10 | cycrow | 154 | 	void SetCustomMap ( const Utils::String &map ) { m_sCustomMap = map; }
 | 
        
           |  |  | 155 | 	void SetLastReadme ( const Utils::String &r ) { m_sLastReadme = r; }
 | 
        
           | 1 | cycrow | 156 |   | 
        
           |  |  | 157 | 	virtual int GetType () { return TYPE_SPK; }
 | 
        
           | 173 | cycrow | 158 | 	virtual BaseFileType type() const override { return BaseFileType::TYPE_SPK; }
 | 
        
           | 1 | cycrow | 159 |   | 
        
           |  |  | 160 | 	void MergePackage(CBaseFile *p);
 | 
        
           |  |  | 161 |   | 
        
           | 7 | cycrow | 162 | 	// old conversion functions
 | 
        
           | 8 | cycrow | 163 | 	bool convertOld(const Utils::String &sOldFilename);
 | 
        
           | 9 | cycrow | 164 | 	static CSpkFile *convertFromOld(const Utils::String &sOldFilename);
 | 
        
           | 7 | cycrow | 165 |   | 
        
           | 1 | cycrow | 166 | protected:
 | 
        
           |  |  | 167 | 	virtual void Delete ();
 | 
        
           |  |  | 168 | 	virtual void SetDefaults ();
 | 
        
           | 175 | cycrow | 169 | 	virtual bool _checkHeader(const Utils::String header) const override;
 | 
        
           | 1 | cycrow | 170 |   | 
        
           | 7 | cycrow | 171 | 	// old conversion functions
 | 
        
           | 8 | cycrow | 172 | 	unsigned char *_convert_uncompressFile(const Utils::String &sOldFilename, int *pLen);
 | 
        
           | 10 | cycrow | 173 | 	void _convert_parse(const Utils::String &sCmd, const Utils::String &sRest);
 | 
        
           | 8 | cycrow | 174 | 	Utils::String _convert_fileEndString(const Utils::String &sFile);
 | 
        
           | 127 | cycrow | 175 | 	FileType _convert_fileType(const Utils::String &sFile);
 | 
        
           | 8 | cycrow | 176 | 	Utils::String _convert_parseFilename(const Utils::String &sRest, float fVersion, Utils::String *pDir);
 | 
        
           | 10 | cycrow | 177 | 	unsigned char *_convert_parseFile(const Utils::String &s_Cmd, const Utils::String &s_Rest, float fVersion, unsigned char *d);
 | 
        
           | 7 | cycrow | 178 |   | 
        
           | 1 | cycrow | 179 | 	// varibles
 | 
        
           | 10 | cycrow | 180 | 	Utils::String m_sOtherAuthor;
 | 
        
           |  |  | 181 | 	Utils::String m_sOtherName;
 | 
        
           |  |  | 182 | 	Utils::String m_sScriptType;
 | 
        
           | 1 | cycrow | 183 |   | 
        
           |  |  | 184 | 	bool m_bForceProfile;
 | 
        
           |  |  | 185 | 	int m_iPackageType;
 | 
        
           |  |  | 186 | 	int m_iScriptType;
 | 
        
           |  |  | 187 |   | 
        
           |  |  | 188 | 	CLinkList<SWares> m_lWares;
 | 
        
           |  |  | 189 | 	CLinkList<SSettingType> m_lSettings;
 | 
        
           |  |  | 190 |   | 
        
           |  |  | 191 | 	SWares *m_pLastWare;
 | 
        
           |  |  | 192 |   | 
        
           |  |  | 193 | 	// installer varibles
 | 
        
           | 10 | cycrow | 194 | 	Utils::String m_sLastReadme;
 | 
        
           |  |  | 195 | 	Utils::String m_sCustomMap;
 | 
        
           | 1 | cycrow | 196 | };
 |