Subversion Repositories spk

Rev

Rev 166 | Rev 173 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 166 Rev 170
Line 80... Line 80...
80
{
80
{
81
public:
81
public:
82
	CXspFile ();
82
	CXspFile ();
83
	~CXspFile () { this->Delete(); }
83
	~CXspFile () { this->Delete(); }
84
 
84
 
85
	static bool ReadAnimations(CyStringList *lIn, CyStringList *lOut, int startRecord);
85
	static bool ReadAnimations(const Utils::CStringList &lIn, Utils::CStringList &lOut, int startRecord);
86
	static int GetAnimationType(const Utils::String &sType);
86
	static int GetAnimationType(const Utils::String &sType);
87
	static Utils::String TypesListToString(Utils::CList<STypesSection> &list, bool deleteAfter = false);
87
	static Utils::String TypesListToString(Utils::CList<STypesSection> &list, bool deleteAfter = false);
88
 
88
 
89
	bool WriteHeader(CFileIO &file, int iHeader, int iLength);
89
	bool WriteHeader(CFileIO &file, int iHeader, int iLength);
90
 
90
 
Line 118... Line 118...
118
	void SetShipData			(const Utils::String &sData ) { m_sData = sData; _changed(); }
118
	void SetShipData			(const Utils::String &sData ) { m_sData = sData; _changed(); }
119
 
119
 
120
	void SetSceneFile ( C_File *f ) { m_pSceneFile = f; }
120
	void SetSceneFile ( C_File *f ) { m_pSceneFile = f; }
121
	void SetCockpitFile ( C_File *f ) { m_pCockpitFile = f; }
121
	void SetCockpitFile ( C_File *f ) { m_pCockpitFile = f; }
122
 
122
 
123
	void AddAnimation(CyStringList *list);
123
	void addAnimation(const Utils::CStringList &list);
124
	void AddAnimation(const Utils::String &;data) { m_lAnimations.PushBack(CyString(data), true); _changed(); }
124
	void addAnimation(const Utils::String&; data);
125
	void AddBodies(const Utils::String &data);
125
	void addBodies(const Utils::String &data);
126
	void AddBody(const Utils::String &section, const Utils::String &data);
126
	void addBody(const Utils::String &section, const Utils::String &data);
127
	void addCutData(const Utils::String& data);
127
	void addCutData(const Utils::String& data);
128
	void AddText(int id, const Utils::String &name, const Utils::String &desc );
128
	void AddText(int id, const Utils::String &name, const Utils::String &desc );
129
	void AddCockpit(const Utils::String &cockpit, int game, int mask = -1, int index = -1 );
129
	void AddCockpit(const Utils::String &cockpit, int game, int mask = -1, int index = -1 );
130
	void AddCockpitWeapon(const Utils::String &cockpit, int game, int mask);
130
	void AddCockpitWeapon(const Utils::String &cockpit, int game, int mask);
131
	void NewCockpit(const Utils::String &id, const Utils::String &scene, int mask );
131
	void NewCockpit(const Utils::String &id, const Utils::String &scene, int mask );
Line 144... Line 144...
144
	void RemoveShipyard ( int s ) { m_iShipyard &= ~(s); _changed(); }
144
	void RemoveShipyard ( int s ) { m_iShipyard &= ~(s); _changed(); }
145
	void SetShipyard(int s, bool b) { if ( b ) AddShipyard(s); else RemoveShipyard(s); }
145
	void SetShipyard(int s, bool b) { if ( b ) AddShipyard(s); else RemoveShipyard(s); }
146
	void ToggleShipyard(int s) { if ( this->IsShipyard(s) ) RemoveShipyard(s); else AddShipyard(s); }
146
	void ToggleShipyard(int s) { if ( this->IsShipyard(s) ) RemoveShipyard(s); else AddShipyard(s); }
147
 
147
 
148
	bool removeCutData(const Utils::String &cut);
148
	bool removeCutData(const Utils::String &cut);
149
	bool RemoveCockpit(const Utils::String &cockpitid);
149
	bool removeCockpit(const Utils::String &cockpitid);
150
	bool RemoveComponent(const Utils::String &section1, const Utils::String &section2, const Utils::String &data);
150
	bool removeComponent(const Utils::String &section1, const Utils::String &section2, const Utils::String &data);
151
	bool RemoveDummy(const Utils::String &section, const Utils::String &data);
151
	bool removeDummy(const Utils::String &section, const Utils::String &data);
152
	bool RemoveBodies(const Utils::String &body);
152
	bool removeBodies(const Utils::String &body);
153
	bool RemoveAnimation(const Utils::String &ani);
153
	bool removeAnimation(const Utils::String &ani);
154
 
154
 
155
	bool IsSigned() { return false; }
155
	bool IsSigned() { return false; }
156
	bool IsValid ();
156
	bool IsValid ();
157
	bool IsShipyard(int s) { return (m_iShipyard & s) ? true : false; }
157
	bool IsShipyard(int s) { return (m_iShipyard & s) ? true : false; }
158
	bool AnyShipyards() { return (m_iShipyard > 0) ? true : false; }
158
	bool AnyShipyards() { return (m_iShipyard > 0) ? true : false; }
Line 163... Line 163...
163
	virtual int GetType () { return TYPE_XSP; }
163
	virtual int GetType () { return TYPE_XSP; }
164
 
164
 
165
	Utils::String GetShipName(int lang);
165
	Utils::String GetShipName(int lang);
166
	bool ConvertOld(const Utils::String &file);
166
	bool ConvertOld(const Utils::String &file);
167
 
167
 
168
	CyStringList *GetAnimations() { return &m_lAnimations; }
168
	const Utils::CStringList &getAnimations() const { return _lAnimations; }
169
	const Utils::CStringList &getCutData() const { return _lCutData; }
169
	const Utils::CStringList &getCutData() const { return _lCutData; }
170
	CyStringList *GetBodies() { return &m_lBodies; }
170
	const Utils::CStringList &getBodies() const { return _lBodies; }
171
	CLinkList<SWeaponMask> *GetLaserMasks() { return &m_lWeaponMasks; }
171
	CLinkList<SWeaponMask> *GetLaserMasks() { return &m_lWeaponMasks; }
172
	CLinkList<SWeaponMask> *GetMissileMasks() { return &m_lMissileMasks; }
172
	CLinkList<SWeaponMask> *GetMissileMasks() { return &m_lMissileMasks; }
173
	CLinkList<SText> *GetTexts() { return &m_lText; }
173
	CLinkList<SText> *GetTexts() { return &m_lText; }
174
	CLinkList<SDummy> *GetDummies() { return &m_lDummy; }
174
	CLinkList<SDummy> *GetDummies() { return &m_lDummy; }
175
	CLinkList<SComponent> *GetComponents() { return &m_lComponent; }
175
	CLinkList<SComponent> *GetComponents() { return &m_lComponent; }
Line 177... Line 177...
177
	int GetLaserMask(int game, bool getOnly = false);
177
	int GetLaserMask(int game, bool getOnly = false);
178
	int GetMissileMask(int game, bool getOnly = false);
178
	int GetMissileMask(int game, bool getOnly = false);
179
	void SetLaserMask(int game, int mask);
179
	void SetLaserMask(int game, int mask);
180
	void SetMissileMask(int game, int mask);
180
	void SetMissileMask(int game, int mask);
181
 
181
 
182
	void SetCreatedShipData(CShipData *data) { m_sData = data->CreateData().ToString(); }
182
	void SetCreatedShipData(CShipData *data) { m_sData = data->createData(); }
183
	bool AnyTexts() { return !m_lText.empty(); }
183
	bool AnyTexts() { return !m_lText.empty(); }
184
	bool AnyDummies() { return !m_lDummy.empty(); }
184
	bool AnyDummies() { return !m_lDummy.empty(); }
185
	bool AnyComponents() { return !m_lComponent.empty(); }
185
	bool AnyComponents() { return !m_lComponent.empty(); }
186
	bool AnyCockpits() { return !m_lCockpit.empty(); }
186
	bool AnyCockpits() { return !m_lCockpit.empty(); }
187
	bool anyCutData() { return !_lCutData.empty(); }
187
	bool anyCutData() { return !_lCutData.empty(); }
188
	bool AnyBodies() { return !m_lBodies.Empty(); }
188
	bool anyBodies() const { return !_lBodies.empty(); }
189
	bool AnyAnimations() { return !m_lAnimations.Empty(); }
189
	bool anyAnimations() const { return !_lAnimations.empty(); }
190
 
190
 
191
	void clearCutData();
191
	void clearCutData();
-
 
192
	void clearAnimations();
-
 
193
	void clearBodies();
192
 
194
 
193
	Utils::String GetShipClass();
195
	Utils::String GetShipClass();
194
	bool UpdateSigned(bool updateFiles) { m_bSigned = false; return false; }
196
	bool UpdateSigned(bool updateFiles) { m_bSigned = false; return false; }
195
 
197
 
196
	// ship extraction
198
	// ship extraction
197
	bool startExtractShip(CVirtualFileSystem *pVfs, const Utils::String &sId, CProgressInfo *pProgress);
199
	bool startExtractShip(CVirtualFileSystem *pVfs, const Utils::String &sId, CProgressInfo *pProgress);
198
	bool extractShip(CVirtualFileSystem *pVfs, const Utils::String &sId, CProgressInfo *progress);
200
	bool extractShip(CVirtualFileSystem *pVfs, const Utils::String &sId, CProgressInfo *progress);
199
	bool extractSceneFiles(CVirtualFileSystem *pVfs);
201
	bool extractSceneFiles(CVirtualFileSystem *pVfs);
200
	void extractComponants(CVirtualFileSystem *pVfs, CyStringList *sceneModels);
202
	void extractComponants(CVirtualFileSystem *pVfs, const Utils::CStringList &sceneModels);
201
	void extractCutData(CVirtualFileSystem *pVfs, CyStringList *sceneModels, bool add);
203
	void extractCutData(CVirtualFileSystem *pVfs, Utils::CStringList& sceneModels, bool add);
202
	void extractDummies(CVirtualFileSystem *pVfs, CyStringList *sceneModels, bool add);
204
	void extractDummies(CVirtualFileSystem *pVfs, Utils::CStringList& sceneModels, bool add);
203
	void extractTextures(CVirtualFileSystem *pVfs);
205
	void extractTextures(CVirtualFileSystem *pVfs);
204
	bool extractBodies(CVirtualFileSystem *pVfs, CyStringList *sceneModels);
206
	bool extractBodies(CVirtualFileSystem *pVfs, const Utils::CStringList& sceneModels);
205
	bool extractCockpits(CVirtualFileSystem *pVfs);
207
	bool extractCockpits(CVirtualFileSystem *pVfs);
206
 
208
 
207
	void addComponentsToList(CLinkList<SComponentEntry> &componentList);
209
	void addComponentsToList(CLinkList<SComponentEntry> &componentList);
208
	void addDummiesToList(Utils::CList<STypesSection> &list);
210
	void addDummiesToList(Utils::CList<STypesSection> &list);
209
	void addCutDataToList(Utils::CList<STypesSection> &list);
211
	void addCutDataToList(Utils::CList<STypesSection> &list);
210
	void addBodiesToList(Utils::CList<STypesSection> &list);
212
	void addBodiesToList(Utils::CList<STypesSection> &list);
211
	void addAnimationsToList(Utils::CList<STypesSection> &list);
213
	void addAnimationsToList(Utils::CList<STypesSection> &list);
212
 
214
 
213
	bool processSceneFileSection(int section, CVirtualFileSystem *pVfs, CyStringList *lModels, CProgressInfo *progress);
215
	bool processSceneFileSection(int section, CVirtualFileSystem *pVfs, Utils::CStringList &lModels, CProgressInfo *progress);
214
	bool processSceneFiles(CVirtualFileSystem *pVfs, CProgressInfo *progress);
216
	bool processSceneFiles(CVirtualFileSystem *pVfs, CProgressInfo *progress);
215
 
217
 
216
	void PackAllFiles();
218
	void PackAllFiles();
217
	CyStringList *ReadSceneModels();
219
	bool readSceneModels(Utils::CStringList& out);
218
 
220
 
219
	//TODO: convert this
221
	//TODO: convert this
220
	void ExtractTexts(CCatFile *catFile, CCatFile *secondCatFile, int textId);
222
	void ExtractTexts(CCatFile *catFile, CCatFile *secondCatFile, int textId);
221
 
223
 
222
	bool GetTextureList(CyStringList *list, const unsigned char *olddata, size_t size);
224
	bool getTextureList(Utils::CStringList &list, const unsigned char *olddata, size_t size) const;
223
	bool AddTextFromFile(const Utils::String &file, int textId = -1);
225
	bool AddTextFromFile(const Utils::String &file, int textId = -1);
224
	bool ImportBodies(CyStringList *sceneModels, const Utils::String &filename);
226
	bool importBodies(const Utils::CStringList &sceneModels, const Utils::String &filename);
225
	bool ImportCockpits(const Utils::String &filename);
227
	bool ImportCockpits(const Utils::String &filename);
226
	Utils::String FormatShipData(CyStringList *cockpits, int *text, int game);
228
	Utils::String formatShipData(const Utils::CStringList &cockpits, int *text, int game);
227
 
229
 
228
	virtual bool LoadPackageData(const Utils::String &sFirst, const Utils::String &sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons, CProgressInfo *progress = NULL) override;
230
	virtual bool LoadPackageData(const Utils::String &sFirst, const Utils::String &sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons, CProgressInfo *progress = NULL) override;
229
	virtual bool GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons, bool datafile = false) override;
231
	virtual bool GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons, bool datafile = false) override;
230
	virtual void addGeneratedFiles(HZIP &hz);
232
	virtual void addGeneratedFiles(HZIP &hz);
231
 
233
 
Line 233... Line 235...
233
	virtual void Delete ();
235
	virtual void Delete ();
234
	virtual void SetDefaults ();
236
	virtual void SetDefaults ();
235
	virtual bool CheckHeader(const Utils::String header) const;
237
	virtual bool CheckHeader(const Utils::String header) const;
236
	SCockpit *_findCockpit(const Utils::String &sID);
238
	SCockpit *_findCockpit(const Utils::String &sID);
237
	void _addSection(Utils::CList<STypesSection> &list, const Utils::String &section, const Utils::String &data);
239
	void _addSection(Utils::CList<STypesSection> &list, const Utils::String &section, const Utils::String &data);
238
	void _addDataSection(CyStringList& list, Utils::CList<STypesSection>& sectionList, bool bUseFirst);
-
 
239
	void _addDataSection(Utils::CStringList& list, Utils::CList<STypesSection>& sectionList, bool bUseFirst);
240
	void _addDataSection(Utils::CStringList& list, Utils::CList<STypesSection>& sectionList, bool bUseFirst);
240
	bool _addTextFromFile(CFileIO &F, int textId = -1);
241
	bool _addTextFromFile(CFileIO &F, int textId = -1);
241
 
242
 
242
protected:
243
protected:
243
	C_File *m_pSceneFile, *m_pCockpitFile;
244
	C_File *m_pSceneFile, *m_pCockpitFile;
Line 248... Line 249...
248
 
249
 
249
	Utils::String m_sID;
250
	Utils::String m_sID;
250
	Utils::String m_sData;
251
	Utils::String m_sData;
251
 
252
 
252
	Utils::CStringList		_lCutData;
253
	Utils::CStringList		_lCutData;
253
	CyStringList			m_lBodies;
254
	Utils::CStringList		_lBodies;
254
	CyStringList			m_lAnimations;
255
	Utils::CStringList		_lAnimations;
255
	CLinkList<SCockpit>		m_lCockpit;
256
	CLinkList<SCockpit>		m_lCockpit;
256
	CLinkList<SText>		m_lText;
257
	CLinkList<SText>		m_lText;
257
	CLinkList<SComponent>	m_lComponent;
258
	CLinkList<SComponent>	m_lComponent;
258
	CLinkList<SDummy>		m_lDummy;
259
	CLinkList<SDummy>		m_lDummy;
259
	CLinkList<SWeaponMask>  m_lWeaponMasks;
260
	CLinkList<SWeaponMask>  m_lWeaponMasks;