1 |
cycrow |
1 |
#pragma once
|
6 |
cycrow |
2 |
#include "BaseFile.h"
|
1 |
cycrow |
3 |
|
|
|
4 |
tstruct SSettingType {
|
|
|
5 |
CyString sKey;
|
|
|
6 |
int iType;
|
|
|
7 |
} SSettingType;
|
|
|
8 |
|
|
|
9 |
typedef struct SWaresText {
|
|
|
10 |
int iLang;
|
|
|
11 |
CyString sName;
|
|
|
12 |
CyString sDesc;
|
|
|
13 |
} SWaresText;
|
|
|
14 |
|
|
|
15 |
typedef struct SWares {
|
|
|
16 |
CyString sID;
|
|
|
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; }
|
|
|
68 |
CyString sValue;
|
|
|
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:
|
|
|
82 |
static int ConvertScriptType(CyString sType);
|
|
|
83 |
static CyString GetScriptTypeStringStatic(int type);
|
|
|
84 |
static CyString GetWareText(SWares *w, int lang);
|
|
|
85 |
static CyString GetWareDesc(SWares *w, int lang);
|
|
|
86 |
|
|
|
87 |
// get functions
|
|
|
88 |
CyString GetScriptTypeString(int lang);
|
|
|
89 |
CyString GetCustomScriptType () { return m_sScriptType; }
|
|
|
90 |
CyString GetCustomScriptType (int lang);
|
|
|
91 |
CyString GetOtherName () { return m_sOtherName; }
|
|
|
92 |
CyString GetOtherAuthor () { return m_sOtherAuthor; }
|
|
|
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; }
|
|
|
102 |
bool IsAnotherMod() { if ( (m_sOtherName.Empty()) || (m_sOtherAuthor.Empty()) ) return false; return true; }
|
|
|
103 |
bool IsForceProfile() { return m_bForceProfile; }
|
|
|
104 |
int GetScriptType() { return m_iScriptType; }
|
|
|
105 |
int GetPackageType() { return m_iPackageType; }
|
|
|
106 |
|
|
|
107 |
// Custom Start
|
|
|
108 |
CyString GetCustomStartName();
|
|
|
109 |
|
|
|
110 |
// set functions
|
|
|
111 |
void SetScriptType ( CyString str ) { m_sScriptType = str; m_bChanged = true; }
|
|
|
112 |
void SetAnotherMod ( CyString name, CyString author ) { m_sOtherName = name; m_sOtherAuthor = author; m_bChanged = true; }
|
|
|
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 |
|
|
|
140 |
bool IsMatchingMod ( CyString mod );
|
|
|
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 |
|
|
|
150 |
SWares *FindWare ( CyString id );
|
|
|
151 |
void AddWare ( CyString );
|
|
|
152 |
void AddWareText ( CyString );
|
|
|
153 |
void AddWare ( SWares * );
|
|
|
154 |
void AddWareText ( SWares *, int, CyString, CyString );
|
|
|
155 |
void RemoveWare ( CyString );
|
|
|
156 |
void RemoveWareText ( CyString, int );
|
|
|
157 |
void ClearWareText ( SWares * );
|
|
|
158 |
void ClearWareText ( CyString );
|
|
|
159 |
void ClearWares ();
|
|
|
160 |
bool AnyWares() { return !m_lWares.empty(); }
|
|
|
161 |
|
|
|
162 |
int CheckValidCustomStart ();
|
|
|
163 |
|
|
|
164 |
bool UpdateSigned (bool updateFiles);
|
|
|
165 |
|
|
|
166 |
SSettingType *AddSetting ( CyString key, int type );
|
|
|
167 |
void ClearSettings ();
|
|
|
168 |
void ConvertSetting ( SSettingType *t, CyString set );
|
|
|
169 |
CyString GetSetting ( SSettingType *t );
|
|
|
170 |
bool AnySettings() { return !m_lSettings.empty(); }
|
|
|
171 |
|
|
|
172 |
// installer usage
|
|
|
173 |
CyString GetLastReadme () { return m_sLastReadme; }
|
|
|
174 |
CyString GetCustomMap () { return m_sCustomMap; }
|
|
|
175 |
|
|
|
176 |
void SetCustomMap ( CyString map ) { m_sCustomMap = map; }
|
|
|
177 |
void SetLastReadme ( CyString r ) { m_sLastReadme = r; }
|
|
|
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);
|
|
|
194 |
void _convert_parse(const Utils::String &sCmd, const Utils::String &sRest, bool bVerbose);
|
|
|
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);
|
|
|
198 |
unsigned char *_convert_parseFile(const Utils::String &s_Cmd, const Utils::String &s_Rest, float fVersion, unsigned char *d, bool bVerbose );
|
7 |
cycrow |
199 |
|
1 |
cycrow |
200 |
// varibles
|
|
|
201 |
CyString m_sOtherAuthor;
|
|
|
202 |
CyString m_sOtherName;
|
|
|
203 |
CyString m_sScriptType;
|
|
|
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
|
|
|
215 |
CyString m_sLastReadme;
|
|
|
216 |
CyString m_sCustomMap;
|
|
|
217 |
};
|