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; }
|
214 |
cycrow |
41 |
Utils::WString sValue;
|
6 |
cycrow |
42 |
} SSettingString;
|
1 |
cycrow |
43 |
|
6 |
cycrow |
44 |
typedef struct SSettingInteger : public SSettingType {
|
214 |
cycrow |
45 |
SSettingInteger () : iValue(0) { iType = SETTING_INTEGER; }
|
6 |
cycrow |
46 |
int iValue;
|
|
|
47 |
} SSettingInteger;
|
1 |
cycrow |
48 |
|
6 |
cycrow |
49 |
typedef struct SSettingCheck : public SSettingType {
|
214 |
cycrow |
50 |
SSettingCheck () : bValue(false) { iType = SETTING_CHECK; }
|
6 |
cycrow |
51 |
bool bValue ;
|
|
|
52 |
} SSettingCheck;
|
1 |
cycrow |
53 |
|
13 |
cycrow |
54 |
|
1 |
cycrow |
55 |
public:
|
214 |
cycrow |
56 |
static int ConvertScriptType(const Utils::WString &sType);
|
|
|
57 |
static Utils::WString 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
|
214 |
cycrow |
62 |
Utils::WString scriptTypeString(int lang) const;
|
|
|
63 |
Utils::WString customScriptType () const { return m_sScriptType; }
|
|
|
64 |
Utils::WString customScriptType (int lang) const;
|
|
|
65 |
const Utils::WString &otherName() const { return m_sOtherName; }
|
|
|
66 |
const Utils::WString &otherAuthor() const { return m_sOtherAuthor; }
|
1 |
cycrow |
67 |
CLinkList<SWares> *GetWaresList() { return &m_lWares; }
|
214 |
cycrow |
68 |
CLinkList<SSettingType> *settingsList() { return &m_lSettings; }
|
1 |
cycrow |
69 |
|
13 |
cycrow |
70 |
bool CheckValidReadmes () const;
|
1 |
cycrow |
71 |
|
13 |
cycrow |
72 |
bool IsCustomStart () const { return (m_iPackageType == PACKAGETYPE_CUSTOMSTART) ? true : false; }
|
|
|
73 |
bool IsPackageUpdate () const { return (m_iPackageType == PACKAGETYPE_UPDATE) ? true : false; }
|
|
|
74 |
bool IsPatch () const { return (m_iPackageType == PACKAGETYPE_PATCH) ? true: false; }
|
|
|
75 |
bool IsLibrary () const { return (m_iPackageType == PACKAGETYPE_LIBRARY) ? true: false; }
|
133 |
cycrow |
76 |
bool IsAnotherMod() const { if ((m_sOtherName.empty()) || (m_sOtherAuthor.empty())) return false; return true; }
|
|
|
77 |
bool isAnotherMod() const { if ((m_sOtherName.empty()) || (m_sOtherAuthor.empty())) return false; return true; }
|
13 |
cycrow |
78 |
bool IsForceProfile() const { return m_bForceProfile; }
|
|
|
79 |
int GetScriptType() const { return m_iScriptType; }
|
|
|
80 |
int GetPackageType() const { return m_iPackageType; }
|
1 |
cycrow |
81 |
|
216 |
cycrow |
82 |
virtual bool readWares(int iLang, CLinkList<SWareEntry> &list, const Utils::WString &empWares);
|
88 |
cycrow |
83 |
|
1 |
cycrow |
84 |
// Custom Start
|
216 |
cycrow |
85 |
Utils::WString customStartName() const;
|
1 |
cycrow |
86 |
|
|
|
87 |
// set functions
|
214 |
cycrow |
88 |
void setScriptType ( const Utils::WString &str ) { m_sScriptType = str; _changed(); }
|
|
|
89 |
void setAnotherMod ( const Utils::WString &name, const Utils::WString &author ) { m_sOtherName = name; m_sOtherAuthor = author; _changed(); }
|
50 |
cycrow |
90 |
void SetForceProfile ( bool p ) { m_bForceProfile = p; _changed(); }
|
1 |
cycrow |
91 |
|
|
|
92 |
void SetPackageType(int i)
|
|
|
93 |
{
|
|
|
94 |
m_iPackageType = i;
|
|
|
95 |
if ( i == PACKAGETYPE_UPDATE )
|
|
|
96 |
{
|
203 |
cycrow |
97 |
if ( !this->findPackageNeeded(L"<package>", L"<author>") )
|
213 |
cycrow |
98 |
this->addNeededLibrary(L"<package>", L"<author>", L"1.00");
|
1 |
cycrow |
99 |
}
|
|
|
100 |
else
|
203 |
cycrow |
101 |
this->removePackageNeeded(L"<package>", L"<author>");
|
50 |
cycrow |
102 |
_changed();
|
1 |
cycrow |
103 |
}
|
|
|
104 |
void SetPatch() { this->SetPackageType(PACKAGETYPE_PATCH); }
|
|
|
105 |
void SetLibrary() { this->SetPackageType(PACKAGETYPE_LIBRARY); }
|
|
|
106 |
void SetCustomStart() { this->SetPackageType(PACKAGETYPE_CUSTOMSTART); }
|
|
|
107 |
void SetPackageUpdate() { this->SetPackageType(PACKAGETYPE_UPDATE); }
|
|
|
108 |
void SetNormalPackage() { this->SetPackageType(PACKAGETYPE_NORMAL); }
|
214 |
cycrow |
109 |
void setScriptType(int i) { SetNormalPackage(); m_iScriptType = i; _changed(); }
|
1 |
cycrow |
110 |
|
197 |
cycrow |
111 |
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;
|
210 |
cycrow |
112 |
virtual bool GeneratePackagerScript(bool wildcard, Utils::WStringList *list, int game, const Utils::WStringList &gameAddons, bool datafile = false) override;
|
1 |
cycrow |
113 |
|
|
|
114 |
CSpkFile();
|
|
|
115 |
virtual ~CSpkFile();
|
|
|
116 |
|
216 |
cycrow |
117 |
bool isMatchingMod(const Utils::WString &mod) const;
|
1 |
cycrow |
118 |
|
|
|
119 |
/// reading of files
|
207 |
cycrow |
120 |
virtual bool parseValueLine(const Utils::WString &line) override;
|
1 |
cycrow |
121 |
|
|
|
122 |
// writing of files
|
207 |
cycrow |
123 |
virtual Utils::WString createValuesLine() const override;
|
175 |
cycrow |
124 |
bool writeHeader(CFileIO &file, int iHeader, int iLength) const override;
|
1 |
cycrow |
125 |
|
216 |
cycrow |
126 |
SWares *findWare(const Utils::WString &id) const;
|
|
|
127 |
void addWare(const Utils::WString &sWareLine);
|
197 |
cycrow |
128 |
void addWareText(const Utils::WString &sText);
|
216 |
cycrow |
129 |
void addWare(SWares *pWare);
|
197 |
cycrow |
130 |
void addWareText(SWares *pWare, int iLang, const Utils::WString &sName, const Utils::WString &sDesc);
|
216 |
cycrow |
131 |
void removeWare(const Utils::WString &sWare);
|
|
|
132 |
void removeWareText(const Utils::WString &sName, int iLang);
|
|
|
133 |
void clearWareText(SWares *pWare);
|
|
|
134 |
void clearWareText(const Utils::WString &sWare);
|
|
|
135 |
void clearWares ();
|
|
|
136 |
bool anyWares() const { return !m_lWares.empty(); }
|
1 |
cycrow |
137 |
|
13 |
cycrow |
138 |
int CheckValidCustomStart () const;
|
1 |
cycrow |
139 |
|
175 |
cycrow |
140 |
virtual bool computeSigned(bool updateFiles) const override;
|
1 |
cycrow |
141 |
|
214 |
cycrow |
142 |
SSettingType *addSetting(const Utils::WString &key, int type);
|
|
|
143 |
void clearSettings ();
|
|
|
144 |
void convertSetting(SSettingType *t, const Utils::WString &set) const;
|
|
|
145 |
Utils::WString getSetting(SSettingType *t) const;
|
|
|
146 |
bool anySettings() const { return !m_lSettings.empty(); }
|
1 |
cycrow |
147 |
|
|
|
148 |
// installer usage
|
214 |
cycrow |
149 |
const Utils::WString &lastReadme () const { return m_sLastReadme; }
|
|
|
150 |
const Utils::WString &customMap () const { return m_sCustomMap; }
|
1 |
cycrow |
151 |
|
214 |
cycrow |
152 |
void setCustomMap ( const Utils::WString &map ) { m_sCustomMap = map; }
|
|
|
153 |
void setLastReadme ( const Utils::WString &r ) { m_sLastReadme = r; }
|
1 |
cycrow |
154 |
|
|
|
155 |
virtual int GetType () { return TYPE_SPK; }
|
173 |
cycrow |
156 |
virtual BaseFileType type() const override { return BaseFileType::TYPE_SPK; }
|
1 |
cycrow |
157 |
|
|
|
158 |
void MergePackage(CBaseFile *p);
|
|
|
159 |
|
7 |
cycrow |
160 |
// old conversion functions
|
216 |
cycrow |
161 |
bool convertOld(const Utils::WString &sOldFilename);
|
|
|
162 |
static CSpkFile *convertFromOld(const Utils::WString &sOldFilename);
|
7 |
cycrow |
163 |
|
1 |
cycrow |
164 |
protected:
|
|
|
165 |
virtual void Delete ();
|
|
|
166 |
virtual void SetDefaults ();
|
210 |
cycrow |
167 |
virtual bool _checkHeader(const Utils::WString &header) const override;
|
1 |
cycrow |
168 |
|
7 |
cycrow |
169 |
// old conversion functions
|
216 |
cycrow |
170 |
unsigned char *_convert_uncompressFile(const Utils::WString &sOldFilename, int *pLen);
|
|
|
171 |
void _convert_parse(const Utils::WString &sCmd, const Utils::WString &sRest);
|
|
|
172 |
Utils::WString _convert_fileEndString(const Utils::WString &sFile);
|
|
|
173 |
FileType _convert_fileType(const Utils::WString &sFile);
|
|
|
174 |
Utils::WString _convert_parseFilename(const Utils::WString &sRest, float fVersion, Utils::WString *pDir);
|
|
|
175 |
unsigned char *_convert_parseFile(const Utils::WString &s_Cmd, const Utils::WString &s_Rest, float fVersion, unsigned char *d);
|
7 |
cycrow |
176 |
|
1 |
cycrow |
177 |
// varibles
|
214 |
cycrow |
178 |
Utils::WString m_sOtherAuthor;
|
|
|
179 |
Utils::WString m_sOtherName;
|
|
|
180 |
Utils::WString m_sScriptType;
|
1 |
cycrow |
181 |
|
|
|
182 |
bool m_bForceProfile;
|
|
|
183 |
int m_iPackageType;
|
|
|
184 |
int m_iScriptType;
|
|
|
185 |
|
|
|
186 |
CLinkList<SWares> m_lWares;
|
|
|
187 |
CLinkList<SSettingType> m_lSettings;
|
|
|
188 |
|
|
|
189 |
SWares *m_pLastWare;
|
|
|
190 |
|
|
|
191 |
// installer varibles
|
214 |
cycrow |
192 |
Utils::WString m_sLastReadme;
|
|
|
193 |
Utils::WString m_sCustomMap;
|
1 |
cycrow |
194 |
};
|