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