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