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