1 |
cycrow |
1 |
#ifndef _XSPFILE_H__
|
|
|
2 |
#define _XSPFILE_H__
|
|
|
3 |
|
6 |
cycrow |
4 |
#include "BaseFile.h"
|
1 |
cycrow |
5 |
#include "ShipData.h"
|
|
|
6 |
#include "StringList.h"
|
|
|
7 |
|
|
|
8 |
class CCatFile;
|
|
|
9 |
|
|
|
10 |
#define SHIPYARD_NONE 0
|
|
|
11 |
#define SHIPYARD_ARGON 1
|
|
|
12 |
#define SHIPYARD_BORON 2
|
|
|
13 |
#define SHIPYARD_PARANID 4
|
|
|
14 |
#define SHIPYARD_SPLIT 8
|
|
|
15 |
#define SHIPYARD_TELADI 16
|
|
|
16 |
#define SHIPYARD_PIRATES 32
|
|
|
17 |
#define SHIPYARD_FRIEND 64
|
|
|
18 |
#define SHIPYARD_XENON 128
|
|
|
19 |
#define SHIPYARD_TERRAN 256
|
|
|
20 |
#define SHIPYARD_ATF 512
|
|
|
21 |
#define SHIPYARD_YAKI 1024
|
|
|
22 |
|
|
|
23 |
#define SHIPYARD_MAX SHIPYARD_TERRAN
|
|
|
24 |
|
|
|
25 |
enum {TAT_NONE, TAT_SINGLE, TAT_3};
|
|
|
26 |
|
|
|
27 |
#define TSHIPPOS_CLASS 53
|
|
|
28 |
|
|
|
29 |
enum {IMPORTSHIP_NONE, IMPORTSHIP_SCENE, IMPORTSHIP_EXTRACTSCENE, IMPORTSHIP_DUMMIES, IMPORTSHIP_COMPONANT, IMPORTSHIP_MODELS, IMPORTSHIP_TEXTURES, IMPORTSHIP_TEXTS, IMPORTSHIP_BODIES, IMPORTSHIP_COCKPITS, IMPORTSHIP_PACK, IMPORTSHIP_DONE};
|
|
|
30 |
|
|
|
31 |
int SPKEXPORT GetMaxShipyards ();
|
|
|
32 |
CyString SPKEXPORT GetShipyardName (int s);
|
|
|
33 |
|
|
|
34 |
typedef struct SWeaponMask {
|
|
|
35 |
int iMask;
|
|
|
36 |
int iGame;
|
|
|
37 |
} SWeaponMask;
|
|
|
38 |
|
|
|
39 |
typedef struct SText
|
|
|
40 |
{
|
|
|
41 |
int iId;
|
|
|
42 |
CyString sName;
|
|
|
43 |
CyString sDesc;
|
|
|
44 |
} SText;
|
|
|
45 |
|
|
|
46 |
typedef struct SDummy
|
|
|
47 |
{
|
|
|
48 |
CyString sSection;
|
|
|
49 |
CyString sData;
|
|
|
50 |
} SDummy;
|
|
|
51 |
|
|
|
52 |
typedef struct SComponent
|
|
|
53 |
{
|
|
|
54 |
CyString sSection;
|
|
|
55 |
CyString sSection2;
|
|
|
56 |
CyString sData;
|
|
|
57 |
} SComponent;
|
|
|
58 |
|
|
|
59 |
typedef struct SCockpit
|
|
|
60 |
{
|
|
|
61 |
CyString sCockpit;
|
|
|
62 |
CLinkList<SWeaponMask> lWeaponMask;
|
|
|
63 |
int iIndex;
|
|
|
64 |
} SCockpit;
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
class SPKEXPORT CXspFile : public CBaseFile
|
|
|
68 |
{
|
|
|
69 |
public:
|
|
|
70 |
CXspFile ();
|
|
|
71 |
~CXspFile () { this->Delete(); }
|
|
|
72 |
|
|
|
73 |
static bool ReadAnimations(CyStringList *lIn, CyStringList *lOut, int startRecord);
|
|
|
74 |
static int GetAnimationType(CyString type);
|
|
|
75 |
|
|
|
76 |
virtual bool WriteHeader ( FILE *id, int, int );
|
|
|
77 |
|
|
|
78 |
bool IsLanguageText () { return m_bLanguageText; }
|
|
|
79 |
bool IsExistingShip () { return m_bExistingShip; }
|
|
|
80 |
|
|
|
81 |
int GetOriginalDescription () { return m_iOrgDesc; }
|
|
|
82 |
int GetShipyards () { return m_iShipyard; }
|
|
|
83 |
|
14 |
cycrow |
84 |
const Utils::String &GetShipID () const { return m_sID; }
|
|
|
85 |
const Utils::String &GetShipData () const { return m_sData; }
|
1 |
cycrow |
86 |
CyString GetX3ShipData();
|
|
|
87 |
CyString GetTCShipData();
|
|
|
88 |
CyString GetShipFilename ()
|
|
|
89 |
{
|
|
|
90 |
CyString s = m_sName + "-" + m_sAuthor;
|
|
|
91 |
s = s.Remove ( ' ' );
|
|
|
92 |
s = s.Remove ( '\\' );
|
|
|
93 |
s = s.Remove ( '/' );
|
|
|
94 |
return s;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
SText *FindShipText(int lang);
|
|
|
98 |
CyString GetTextName(int lang);
|
|
|
99 |
CyString GetTextDescription(int lang);
|
|
|
100 |
|
|
|
101 |
void SetLanguageText ( bool b ) { m_bLanguageText = b; m_bChanged = true; }
|
|
|
102 |
void SetExistingShip ( bool b ) { m_bExistingShip = b; m_bChanged = true; }
|
|
|
103 |
void SetOriginalDescription ( int i ) { m_iOrgDesc = i; m_bChanged = true; }
|
14 |
cycrow |
104 |
void SetShipID (const Utils::String &sId ) { m_sID = sId; m_bChanged = true; }
|
|
|
105 |
void SetShipData (const Utils::String &sData ) { m_sData = sData; m_bChanged = true; }
|
1 |
cycrow |
106 |
|
|
|
107 |
void SetSceneFile ( C_File *f ) { m_pSceneFile = f; }
|
|
|
108 |
void SetCockpitFile ( C_File *f ) { m_pCockpitFile = f; }
|
|
|
109 |
|
|
|
110 |
void AddAnimation(CyStringList *list);
|
|
|
111 |
void AddAnimation(CyString data) { m_lAnimations.PushBack(data, true); m_bChanged = true; }
|
|
|
112 |
void AddBodies(CyString data);
|
|
|
113 |
void AddBody(CyString section, CyString data);
|
|
|
114 |
void AddCutData(CyString data) { m_lCutData.PushBack(data, true); m_bChanged = true; }
|
|
|
115 |
void AddText ( int id, CyString name, CyString desc );
|
|
|
116 |
void AddCockpit ( CyString cockpit, int game, int mask = -1, int index = -1 );
|
|
|
117 |
void NewCockpit ( CyString id, CyString scene, int mask );
|
|
|
118 |
void EditCockpit ( CyString id, CyString cockpit);
|
|
|
119 |
void EditCockpit(CyString id, CyString scene, int mask);
|
|
|
120 |
CyString GetCockpitData(CyString id);
|
|
|
121 |
SCockpit *FindCockpit(CyString id);
|
|
|
122 |
void AddDummy ( CyString section, CyString data );
|
|
|
123 |
void AddComponent ( CyString section, CyString section2, CyString data );
|
|
|
124 |
void AddWeaponMask ( int game, int mask );
|
|
|
125 |
void AddMissileMask ( int game, int mask );
|
|
|
126 |
void RemoveText(int id);
|
|
|
127 |
void ClearText() { m_lText.MemoryClear(); m_bChanged = true; }
|
|
|
128 |
|
|
|
129 |
void AddShipyard ( int s ) { m_iShipyard |= s; m_bChanged = true; }
|
|
|
130 |
void RemoveShipyard ( int s ) { m_iShipyard &= ~(s); m_bChanged = true; }
|
|
|
131 |
void SetShipyard(int s, bool b) { if ( b ) AddShipyard(s); else RemoveShipyard(s); }
|
|
|
132 |
void ToggleShipyard(int s) { if ( this->IsShipyard(s) ) RemoveShipyard(s); else AddShipyard(s); }
|
|
|
133 |
|
|
|
134 |
bool RemoveCutData(CyString cut);
|
|
|
135 |
bool RemoveCockpit(CyString cockpitid);
|
|
|
136 |
bool RemoveComponent(CyString section1, CyString section2, CyString data);
|
|
|
137 |
bool RemoveDummy(CyString section, CyString data);
|
|
|
138 |
bool RemoveBodies(CyString body);
|
|
|
139 |
bool RemoveAnimation(CyString ani);
|
|
|
140 |
|
|
|
141 |
bool IsSigned() { return false; }
|
|
|
142 |
bool IsValid ();
|
|
|
143 |
bool IsShipyard(int s) { return (m_iShipyard & s) ? true : false; }
|
|
|
144 |
bool AnyShipyards() { return (m_iShipyard > 0) ? true : false; }
|
|
|
145 |
void AdjustCockpits();
|
14 |
cycrow |
146 |
virtual Utils::String CreateValuesLine () const;
|
|
|
147 |
virtual bool ParseValueLine(const Utils::String &line);
|
1 |
cycrow |
148 |
|
|
|
149 |
virtual int GetType () { return TYPE_XSP; }
|
|
|
150 |
|
|
|
151 |
CyString GetShipName(int lang);
|
|
|
152 |
bool ConvertOld(CyString file);
|
|
|
153 |
|
|
|
154 |
CyStringList *GetAnimations() { return &m_lAnimations; }
|
|
|
155 |
CyStringList *GetCutData() { return &m_lCutData; }
|
|
|
156 |
CyStringList *GetBodies() { return &m_lBodies; }
|
|
|
157 |
CLinkList<SWeaponMask> *GetLaserMasks() { return &m_lWeaponMasks; }
|
|
|
158 |
CLinkList<SWeaponMask> *GetMissileMasks() { return &m_lMissileMasks; }
|
|
|
159 |
CLinkList<SText> *GetTexts() { return &m_lText; }
|
|
|
160 |
CLinkList<SDummy> *GetDummies() { return &m_lDummy; }
|
|
|
161 |
CLinkList<SComponent> *GetComponents() { return &m_lComponent; }
|
|
|
162 |
CLinkList<SCockpit> *GetCockpits() { return &m_lCockpit; }
|
|
|
163 |
int GetLaserMask(int game, bool getOnly = false);
|
|
|
164 |
int GetMissileMask(int game, bool getOnly = false);
|
|
|
165 |
void SetLaserMask(int game, int mask);
|
|
|
166 |
void SetMissileMask(int game, int mask);
|
|
|
167 |
|
14 |
cycrow |
168 |
void SetCreatedShipData(CShipData *data) { m_sData = data->CreateData().ToString(); }
|
1 |
cycrow |
169 |
bool AnyTexts() { return !m_lText.empty(); }
|
|
|
170 |
bool AnyDummies() { return !m_lDummy.empty(); }
|
|
|
171 |
bool AnyComponents() { return !m_lComponent.empty(); }
|
|
|
172 |
bool AnyCockpits() { return !m_lCockpit.empty(); }
|
|
|
173 |
bool AnyCutData() { return !m_lCutData.Empty(); }
|
|
|
174 |
bool AnyBodies() { return !m_lBodies.Empty(); }
|
|
|
175 |
bool AnyAnimations() { return !m_lAnimations.Empty(); }
|
|
|
176 |
|
|
|
177 |
CyString GetShipClass();
|
|
|
178 |
|
|
|
179 |
// ship extraction
|
|
|
180 |
bool StartExtractShip(CyString catFile, CyString id, CProgressInfo *progress);
|
|
|
181 |
bool StartExtractShip(CCatFile *catFile, CyString id, CProgressInfo *progress);
|
|
|
182 |
bool ExtractShip(CCatFile *catFile, CyString id, CProgressInfo *progress);
|
|
|
183 |
bool ExtractShip(CyString catFile, CyString id, CProgressInfo *progress);
|
|
|
184 |
C_File *ExtractFileToPackage(CCatFile *catFile, CyString file, int type, CyString addAs = NullString);
|
|
|
185 |
|
|
|
186 |
bool ExtractSceneFiles(CCatFile *catFile);
|
|
|
187 |
bool ExtractSceneFiles(CyString catFile);
|
|
|
188 |
|
|
|
189 |
bool ProcessSceneFileSection(int section, CCatFile *catFile, CyStringList *lModels, CProgressInfo *progress);
|
|
|
190 |
bool ProcessSceneFiles(CCatFile *catFile, CProgressInfo *progress);
|
|
|
191 |
bool ProcessSceneFiles(CyString catFile, CProgressInfo *progress);
|
|
|
192 |
|
|
|
193 |
bool UpdateSigned(bool updateFiles) { m_bSigned = false; return false; }
|
|
|
194 |
void PackAllFiles();
|
|
|
195 |
CyStringList *ReadSceneModels();
|
|
|
196 |
void ExtractComponants(CCatFile *catFile, CyStringList *sceneModels);
|
|
|
197 |
void ExtractDummies(CCatFile *catFile, CyStringList *sceneModels, bool add);
|
|
|
198 |
void ExtractTextures(CCatFile *catFile);
|
|
|
199 |
bool GetTextureList(CyStringList *list, const unsigned char *olddata, size_t size);
|
|
|
200 |
void ExtractTexts(CCatFile *catFile, int textId);
|
|
|
201 |
bool AddTextFromFile(FILE *id, int textId = -1);
|
|
|
202 |
bool AddTextFromFile(CyString file, int textId = -1);
|
|
|
203 |
bool ExtractBodies(CCatFile *catFile, CyStringList *sceneModels);
|
|
|
204 |
bool ImportBodies(CyStringList *sceneModels, CyString filename);
|
|
|
205 |
bool ExtractCockpits(CCatFile *catFile);
|
|
|
206 |
bool ImportCockpits(CyString filename);
|
|
|
207 |
CyString FormatShipData(CyStringList *cockpits, int *text, int game);
|
|
|
208 |
|
14 |
cycrow |
209 |
virtual bool LoadPackageData(const Utils::String &sFfirst, const Utils::String &sRest);
|
1 |
cycrow |
210 |
virtual bool GeneratePackagerScript(bool wildcard, CyStringList *list, bool datafile = false);
|
|
|
211 |
|
|
|
212 |
protected:
|
|
|
213 |
virtual void Delete ();
|
|
|
214 |
virtual void SetDefaults ();
|
14 |
cycrow |
215 |
virtual bool CheckHeader(const Utils::String header) const;
|
1 |
cycrow |
216 |
|
|
|
217 |
C_File *m_pSceneFile, *m_pCockpitFile;
|
|
|
218 |
|
|
|
219 |
bool m_bLanguageText, m_bExistingShip;
|
|
|
220 |
|
|
|
221 |
int m_iOrgDesc;
|
|
|
222 |
|
14 |
cycrow |
223 |
Utils::String m_sID;
|
|
|
224 |
Utils::String m_sData;
|
1 |
cycrow |
225 |
|
|
|
226 |
CyStringList m_lCutData;
|
|
|
227 |
CyStringList m_lBodies;
|
|
|
228 |
CyStringList m_lAnimations;
|
|
|
229 |
CLinkList<SCockpit> m_lCockpit;
|
|
|
230 |
CLinkList<SText> m_lText;
|
|
|
231 |
CLinkList<SComponent> m_lComponent;
|
|
|
232 |
CLinkList<SDummy> m_lDummy;
|
|
|
233 |
CLinkList<SWeaponMask> m_lWeaponMasks;
|
|
|
234 |
CLinkList<SWeaponMask> m_lMissileMasks;
|
|
|
235 |
|
|
|
236 |
int m_iShipyard;
|
|
|
237 |
};
|
|
|
238 |
|
|
|
239 |
|
|
|
240 |
#endif //_XSPFILE_H__
|
|
|
241 |
|