1 |
cycrow |
1 |
#include "../StdAfx.h"
|
|
|
2 |
#include "PackageForm.h"
|
|
|
3 |
#include "InputBox.h"
|
|
|
4 |
#include "Form1.h"
|
|
|
5 |
#include "AddWareText.h"
|
|
|
6 |
#include "AddCockpit.h"
|
|
|
7 |
#include "SaveDialog.h"
|
|
|
8 |
|
|
|
9 |
namespace Creator {
|
|
|
10 |
bool PackageForm::LoadPackage(CBaseFile *base, System::String ^filename)
|
|
|
11 |
{
|
|
|
12 |
m_sFilename = filename;
|
|
|
13 |
|
|
|
14 |
if ( !base )
|
|
|
15 |
{
|
|
|
16 |
int error;
|
|
|
17 |
m_pPackage = m_pP->OpenPackage(CyStringFromSystemString(filename), &error);
|
|
|
18 |
if ( !m_pPackage )
|
|
|
19 |
return false;
|
|
|
20 |
}
|
|
|
21 |
else
|
|
|
22 |
m_pPackage = base;
|
|
|
23 |
|
|
|
24 |
m_pPackage->SetChanged(false);
|
|
|
25 |
m_pPackage->UpdateSigned(true);
|
|
|
26 |
this->UpdateChanged();
|
|
|
27 |
m_bLoading = true;
|
|
|
28 |
|
|
|
29 |
if ( m_pPackage->AnyFileType(FILETYPE_ADVERT) )
|
|
|
30 |
{
|
|
|
31 |
for ( C_File *f = m_pPackage->GetFirstFile(FILETYPE_ADVERT); f; f = m_pPackage->GetNextFile(f) )
|
|
|
32 |
{
|
|
|
33 |
f->SetFullDir(CyStringFromSystemString(System::IO::Path::GetTempPath()));
|
|
|
34 |
long size;
|
|
|
35 |
unsigned char *data = f->UncompressData(&size, 0);
|
|
|
36 |
if ( data && size )
|
|
|
37 |
{
|
|
|
38 |
if ( f->WriteFilePointer(data, size) )
|
|
|
39 |
{
|
|
|
40 |
if ( !m_pDisplayFile )
|
|
|
41 |
m_pDisplayFile = f;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
if ( f->GetCompressionType() != SPKCOMPRESS_NONE )
|
|
|
45 |
delete data;
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
if ( m_pPackage->GetIcon() )
|
|
|
51 |
{
|
|
|
52 |
C_File *f = m_pPackage->GetIcon();
|
|
|
53 |
f->SetFilename(CyStringFromSystemString(System::IO::Path::GetTempPath()) + "/package_icon." + m_pPackage->GetIconExt());
|
|
|
54 |
f->SetFullDir(CyStringFromSystemString(System::IO::Path::GetTempPath()));
|
|
|
55 |
long size;
|
|
|
56 |
unsigned char *data = f->UncompressData(&size, 0);
|
|
|
57 |
if ( data && size )
|
|
|
58 |
{
|
|
|
59 |
f->WriteFilePointer(data, size);
|
|
|
60 |
if ( f->GetCompressionType() != SPKCOMPRESS_NONE )
|
|
|
61 |
delete data;
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
this->RadioInstallBefore->Checked = true;
|
|
|
66 |
this->RadioInstallAfter->Checked = false;
|
|
|
67 |
this->RadioUninstallAfter->Checked = false;
|
|
|
68 |
this->RadioUninstallBefore->Checked = false;
|
|
|
69 |
this->UpdateView();
|
|
|
70 |
|
|
|
71 |
m_pPackage->SetChanged(false);
|
|
|
72 |
|
|
|
73 |
m_bLoading = false;
|
|
|
74 |
|
|
|
75 |
return true;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
void PackageForm::DoToolTips()
|
|
|
79 |
{
|
|
|
80 |
//tooltip1 for any controls with text to display
|
|
|
81 |
this->toolTip1->SetToolTip(this->RadioTypeUpdate, "This allows you to create a small package to update an already installed one with new files.\nIn the Dependacy section you can set the minimum version required to install.\nAny mod files only need to contain the files you want to update, they will be added into the existing mod file when installed");
|
|
|
82 |
this->toolTip1->SetToolTip(this->RadioTypeStart, "This allows you to create a custom start in the old format\nWhen installed, it will use the added initplayer script to create the maps and jobs file automatically\nThis allows it to always use the most up to date map automatically, so you only need to make changes to the script file\nIf set to use another mod, it'll use the map from the mod instead of the games one");
|
|
|
83 |
this->toolTip1->SetToolTip(this->RadioTypePatch, "This allows you to create patchs to your mod files\nWhen installing, any files in the patch mod will overright the base mod files, allowing you to create different patchs allowing users to customise your mod without having to have seperate mod installs\nWhen the patch is uninstalled, any changed files will be restored back to the normal ones");
|
|
|
84 |
this->toolTip1->SetToolTip(this->CheckShipID, "This allows you to replaing an existing ship when you install\nNormally, the ship is simply added into the game, at the end of the ships file, when set to replace, it will replace the ship with the same ship id.\nThis allows you to create an update to an existing ship without having to have both in the game");
|
|
|
85 |
this->toolTip1->SetToolTip(this->groupBox3, "This allows you to set the parent package\nThis will need to be installed as well, unlike depencies, the child/parent packages are linked to each other\nThis allows you to release updates or addons for a certain package, one that will only work with the parent package");
|
|
|
86 |
this->toolTip1->SetToolTip(this->ButFromFile, "This will read the details from an existing file\nWhen selected, you will be prompted to select a saved package file.\nThe package name and author is then read from the package and automatically filled in so you know its entered correctly");
|
|
|
87 |
this->toolTip1->SetToolTip(this->RadioInstallBefore, "This is a message you can give to the user when they install your package\nThis will come before the installation starts and allows you to display information or warnings about the package they are about to install to help them decide if they want to continue installing or not");
|
|
|
88 |
this->toolTip1->SetToolTip(this->RadioInstallAfter, "This message is displayed to the user once the package has been installed\nThis is usually used to give the user information about your package, like how to start using it in game, or important information before they start using it, etc");
|
|
|
89 |
this->toolTip1->SetToolTip(this->RadioUninstallBefore, "This message is displayed when the user attempts to uninstall your package\nThis can be used to give the user instruction on what else they might need to do to uninstall, ie if theres something they need to do ingame first before removing the package");
|
|
|
90 |
this->toolTip1->SetToolTip(this->RadioUninstallAfter, "This message is displayed after the user has uninstalled your package\nThis can give them information about anything else they might need to do to remove the package, ie to allow the uninstall scripts to function to remove anything from thier game");
|
|
|
91 |
this->toolTip1->SetToolTip(this->GroupEase, "This is a rating allowing the user to see how easy it is to use the script\nThe ratings are displayed when installing the package and are from 1 to 5, 5 being easy to use, 1 being hard\nClicking on the stars will adjust the rating");
|
|
|
92 |
this->toolTip1->SetToolTip(this->GroupChange, "This is a rating allowing the user to see how much the package changes the game\nThe ratings are displayed when installing the package and are from 1 to 5, 5 being alot of change, 1 being very little\nClicking on the stars will adjust the rating");
|
|
|
93 |
this->toolTip1->SetToolTip(this->GroupRec, "This is a rating allowing the user to see how much you recommended this package\nThe ratings are displayed when installing the package and are from 1 to 5, 5 highly recommended\nClicking on the stars will adjust the rating");
|
|
|
94 |
|
|
|
95 |
// controls that need custom title texts using tags
|
|
|
96 |
this->ComboPluginType->Tag = "Plugin Type";
|
|
|
97 |
this->toolTip2->SetToolTip(this->ComboPluginType, "The plugin type is used to display roughly what type the plugin comes under, this is displayed during installation\nNormal = Just a normal package\nStable = A stable or final release of a package\nExperimental = Potentinally unstable package\nCheat = Considered to be a cheat, ie breaks game balance\nMod = A Mod, can only run 1 at a time and not compatable with other mods");
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
void PackageForm::UpdateScriptType()
|
|
|
101 |
{
|
6 |
cycrow |
102 |
if ( this->ComboType->SelectedIndex == CSpkFile::SCRIPTTYPE_CUSTOM )
|
|
|
103 |
{
|
|
|
104 |
this->TextCustomType->Visible = true;
|
|
|
105 |
this->ComboType->Dock = Windows::Forms::DockStyle::Left;
|
|
|
106 |
if ( !m_bLoading )
|
10 |
cycrow |
107 |
((CSpkFile *)m_pPackage)->SetScriptType(CyStringFromSystemString(this->TextCustomType->Text).ToString());
|
1 |
cycrow |
108 |
}
|
|
|
109 |
else
|
|
|
110 |
{
|
|
|
111 |
this->TextCustomType->Visible = false;
|
|
|
112 |
this->ComboType->Dock = Windows::Forms::DockStyle::Fill;
|
|
|
113 |
}
|
|
|
114 |
}
|
|
|
115 |
void PackageForm::UpdateText()
|
|
|
116 |
{
|
|
|
117 |
this->TextText->Tag = 1;
|
|
|
118 |
CLinkList<SInstallText> *list = NULL;
|
|
|
119 |
if ( this->RadioInstallAfter->Checked || this->RadioInstallBefore->Checked )
|
|
|
120 |
list = m_pPackage->GetInstallTextList();
|
|
|
121 |
else if ( this->RadioUninstallAfter->Checked || this->RadioUninstallBefore->Checked )
|
|
|
122 |
list = m_pPackage->GetUninstallTextList();
|
|
|
123 |
else
|
|
|
124 |
{
|
|
|
125 |
this->ListLang->Enabled = false;
|
|
|
126 |
this->ButTextAdd->Enabled = false;
|
|
|
127 |
this->UpdateTextLang();
|
|
|
128 |
return;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
this->ListLang->Enabled = true;
|
|
|
132 |
this->ButTextAdd->Enabled = true;
|
|
|
133 |
|
|
|
134 |
int selected = this->ListLang->SelectedIndex;
|
|
|
135 |
if ( selected >= 1 )
|
|
|
136 |
selected = Convert::ToInt32(this->ListLang->Text);
|
|
|
137 |
else
|
|
|
138 |
selected = -1;
|
|
|
139 |
|
|
|
140 |
this->ListLang->Items->Clear();
|
|
|
141 |
this->ListLang->Items->Add("- Default -");
|
|
|
142 |
|
|
|
143 |
if ( !list )
|
|
|
144 |
{
|
|
|
145 |
this->UpdateTextLang();
|
|
|
146 |
return;
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
bool before = false;
|
|
|
150 |
if ( this->RadioInstallBefore->Checked || this->RadioUninstallBefore->Checked )
|
|
|
151 |
before = true;
|
|
|
152 |
|
|
|
153 |
// add languages
|
|
|
154 |
for ( SInstallText *t = list->First(); t; t = list->Next() )
|
|
|
155 |
{
|
|
|
156 |
if ( t->iLanguage <= 0 )
|
|
|
157 |
continue;
|
|
|
158 |
this->ListLang->Items->Add(System::Convert::ToString(t->iLanguage));
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
if ( selected == -1 )
|
|
|
162 |
this->ListLang->SelectedIndex = 0;
|
|
|
163 |
else
|
|
|
164 |
this->ListLang->Text = Convert::ToString(selected);
|
|
|
165 |
if ( this->ListLang->SelectedIndex == -1 )
|
|
|
166 |
this->ListLang->SelectedIndex = 0;
|
|
|
167 |
|
|
|
168 |
this->UpdateTextLang();
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
void PackageForm::UpdateTextLang()
|
|
|
172 |
{
|
|
|
173 |
this->TextText->Tag = 1;
|
|
|
174 |
this->TextText->Enabled = false;
|
|
|
175 |
this->TextText->Text = "";
|
|
|
176 |
|
|
|
177 |
if ( this->ListLang->SelectedIndex >= 0 )
|
|
|
178 |
{
|
|
|
179 |
int lang = CyStringFromSystemString(this->ListLang->Text).ToInt();
|
|
|
180 |
CyString desc;
|
|
|
181 |
if ( this->RadioInstallAfter->Checked )
|
|
|
182 |
desc = m_pPackage->GetInstallAfterText(lang, true);
|
|
|
183 |
else if ( this->RadioInstallBefore->Checked )
|
|
|
184 |
desc = m_pPackage->GetInstallBeforeText(lang, true);
|
|
|
185 |
else if ( this->RadioUninstallAfter->Checked )
|
|
|
186 |
desc = m_pPackage->GetUninstallAfterText(lang, true);
|
|
|
187 |
else if ( this->RadioUninstallBefore->Checked )
|
|
|
188 |
desc = m_pPackage->GetUninstallBeforeText(lang, true);
|
|
|
189 |
this->TextText->Text = SystemStringFromCyString(desc);
|
|
|
190 |
this->TextText->Enabled = true;
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
this->ButTextDel->Enabled = false;
|
|
|
194 |
if ( this->ListLang->SelectedIndex >= 1 )
|
|
|
195 |
this->ButTextDel->Enabled = true;
|
|
|
196 |
|
|
|
197 |
this->TextText->Tag = nullptr;
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
void PackageForm::UpdateWares()
|
|
|
201 |
{
|
|
|
202 |
CSpkFile *spk = (CSpkFile *)m_pPackage;
|
|
|
203 |
|
|
|
204 |
this->ListWares->Items->Clear();
|
|
|
205 |
for ( SWares *w = spk->GetWaresList()->First(); w; w = spk->GetWaresList()->Next() )
|
|
|
206 |
{
|
|
|
207 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(w->sID));
|
|
|
208 |
switch ( tolower(w->cType) )
|
|
|
209 |
{
|
|
|
210 |
case 'b':
|
|
|
211 |
item->SubItems->Add("Bio");
|
|
|
212 |
break;
|
|
|
213 |
case 'e':
|
|
|
214 |
item->SubItems->Add("Energy");
|
|
|
215 |
break;
|
|
|
216 |
case 'f':
|
|
|
217 |
item->SubItems->Add("Food");
|
|
|
218 |
break;
|
|
|
219 |
case 't':
|
|
|
220 |
item->SubItems->Add("Tech");
|
|
|
221 |
break;
|
|
|
222 |
case 'm':
|
|
|
223 |
item->SubItems->Add("Mineral");
|
|
|
224 |
break;
|
|
|
225 |
default:
|
|
|
226 |
item->SubItems->Add("Other");
|
|
|
227 |
}
|
|
|
228 |
item->SubItems->Add(System::Convert::ToString(w->iPrice));
|
|
|
229 |
switch ( w->iSize )
|
|
|
230 |
{
|
|
|
231 |
case 0:
|
|
|
232 |
item->SubItems->Add("Tiny Containers");
|
|
|
233 |
break;
|
|
|
234 |
case 1:
|
|
|
235 |
item->SubItems->Add("Small Containers (S)");
|
|
|
236 |
break;
|
|
|
237 |
case 2:
|
|
|
238 |
item->SubItems->Add("Medium Containers (M)");
|
|
|
239 |
break;
|
|
|
240 |
case 3:
|
|
|
241 |
item->SubItems->Add("Large Containers (L)");
|
|
|
242 |
break;
|
|
|
243 |
case 4:
|
|
|
244 |
item->SubItems->Add("Extra Large Containers (XL)");
|
|
|
245 |
break;
|
|
|
246 |
case 5:
|
|
|
247 |
item->SubItems->Add("Station Containers (ST)");
|
|
|
248 |
break;
|
|
|
249 |
default:
|
|
|
250 |
item->SubItems->Add("Other Containers");
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
item->SubItems->Add(System::Convert::ToString(w->iVolumn));
|
|
|
254 |
item->SubItems->Add(System::Convert::ToString(w->iNotority));
|
|
|
255 |
|
|
|
256 |
if ( w->iTextPage > 0 && w->iTextID > 0 )
|
|
|
257 |
item->SubItems->Add(System::Convert::ToString(w->iTextPage) + ", " + System::Convert::ToString(w->iTextID));
|
|
|
258 |
item->ImageIndex = 2;
|
|
|
259 |
this->ListWares->Items->Add(item);
|
|
|
260 |
}
|
|
|
261 |
this->ListWares->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
262 |
|
|
|
263 |
this->UpdateWareText();
|
|
|
264 |
m_pPackage->UpdateSigned(false);
|
|
|
265 |
this->UpdateChanged();
|
|
|
266 |
}
|
|
|
267 |
|
|
|
268 |
void PackageForm::UpdateWareText()
|
|
|
269 |
{
|
|
|
270 |
this->ListWareText->Items->Clear();
|
|
|
271 |
this->splitContainer1->Panel2Collapsed = true;
|
|
|
272 |
|
|
|
273 |
if ( this->ListWares->SelectedItems->Count )
|
|
|
274 |
{
|
10 |
cycrow |
275 |
SWares *w = ((CSpkFile *)m_pPackage)->FindWare(CyStringFromSystemString(this->ListWares->SelectedItems[0]->Text).ToString());
|
1 |
cycrow |
276 |
if ( w )
|
|
|
277 |
{
|
|
|
278 |
if ( w->iTextPage <= 0 && w->iTextID <= 0 )
|
|
|
279 |
{
|
|
|
280 |
this->ListWareText->Items->Clear();
|
|
|
281 |
this->splitContainer1->Panel2Collapsed = false;
|
|
|
282 |
for ( SWaresText *wt = w->lText.First(); wt; wt = w->lText.Next() )
|
|
|
283 |
{
|
|
|
284 |
ListViewItem ^item = gcnew ListViewItem(System::Convert::ToString(wt->iLang));
|
|
|
285 |
item->ImageIndex = 0;
|
|
|
286 |
item->SubItems->Add(SystemStringFromCyString(wt->sName));
|
|
|
287 |
item->SubItems->Add(SystemStringFromCyString(wt->sDesc));
|
|
|
288 |
this->ListWareText->Items->Add(item);
|
|
|
289 |
}
|
|
|
290 |
}
|
|
|
291 |
}
|
|
|
292 |
}
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
void PackageForm::UpdateView()
|
|
|
296 |
{
|
|
|
297 |
m_bLoading = true;
|
|
|
298 |
|
|
|
299 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(PackageForm::typeid));
|
|
|
300 |
|
|
|
301 |
this->LabelShipWarning->Visible = false;
|
|
|
302 |
this->TextName->Text = SystemStringFromCyString(m_pPackage->GetName());
|
|
|
303 |
this->TextAuthor->Text = SystemStringFromCyString(m_pPackage->GetAuthor());
|
|
|
304 |
this->TextVersion->Text = SystemStringFromCyString(m_pPackage->GetVersion());
|
|
|
305 |
CyString desc = m_pPackage->GetDescription();
|
|
|
306 |
desc = desc.FindReplace("<br>", "\n");
|
|
|
307 |
desc = desc.FindReplace("<newline>", "\n");
|
|
|
308 |
desc = desc.StripHTML();
|
|
|
309 |
this->TextDesc->Text = SystemStringFromCyString(desc);
|
|
|
310 |
|
|
|
311 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
312 |
{
|
|
|
313 |
CXspFile *xsp = (CXspFile *)m_pPackage;
|
|
|
314 |
this->TextShipID->Text = SystemStringFromCyString(xsp->GetShipID());
|
|
|
315 |
this->PanelShip->Show();
|
|
|
316 |
this->LabelShipWarning->Visible = true;
|
|
|
317 |
this->groupBox6->Visible = false;
|
|
|
318 |
|
|
|
319 |
this->TextShipData->Text = SystemStringFromCyString(xsp->GetShipData());
|
|
|
320 |
|
|
|
321 |
this->CheckShipID->Checked = xsp->IsExistingShip();
|
|
|
322 |
this->CheckExistingText->Checked = (xsp->GetOriginalDescription()) ? true : false;
|
|
|
323 |
if ( xsp->GetOriginalDescription() )
|
|
|
324 |
this->NumTextID->Value = xsp->GetOriginalDescription();
|
|
|
325 |
|
|
|
326 |
// shipyards
|
|
|
327 |
this->CheckSYArgon->Checked = xsp->IsShipyard(SHIPYARD_ARGON);
|
|
|
328 |
this->CheckSYBoron->Checked = xsp->IsShipyard(SHIPYARD_BORON);
|
|
|
329 |
this->CheckSYTeladi->Checked = xsp->IsShipyard(SHIPYARD_TELADI);
|
|
|
330 |
this->CheckSYParanid->Checked = xsp->IsShipyard(SHIPYARD_PARANID);
|
|
|
331 |
this->CheckSYSplit->Checked = xsp->IsShipyard(SHIPYARD_SPLIT);
|
|
|
332 |
this->CheckSYFriend->Checked = xsp->IsShipyard(SHIPYARD_FRIEND);
|
|
|
333 |
this->CheckSYPirate->Checked = xsp->IsShipyard(SHIPYARD_PIRATES);
|
|
|
334 |
this->CheckSYXenon->Checked = xsp->IsShipyard(SHIPYARD_XENON);
|
|
|
335 |
this->CheckSYTerran->Checked = xsp->IsShipyard(SHIPYARD_TERRAN);
|
|
|
336 |
this->CheckSYATF->Checked = xsp->IsShipyard(SHIPYARD_ATF);
|
|
|
337 |
this->CheckSYYaki->Checked = xsp->IsShipyard(SHIPYARD_YAKI);
|
|
|
338 |
|
|
|
339 |
this->UpdateShipText();
|
|
|
340 |
this->UpdateShipPartList();
|
|
|
341 |
}
|
|
|
342 |
else if ( m_pPackage->GetType() == TYPE_SPK )
|
|
|
343 |
{
|
|
|
344 |
CSpkFile *spk = (CSpkFile *)m_pPackage;
|
|
|
345 |
|
|
|
346 |
this->ComboType->Text = "Custom";
|
|
|
347 |
this->ComboType->Enabled = false;
|
|
|
348 |
|
|
|
349 |
this->ComboPluginType->SelectedIndex = spk->GetPluginType();
|
|
|
350 |
|
|
|
351 |
if ( spk->IsLibrary() )
|
|
|
352 |
this->RadioTypeLibrary->Checked = true;
|
|
|
353 |
else if ( spk->IsCustomStart() )
|
|
|
354 |
this->RadioTypeStart->Checked = true;
|
|
|
355 |
else if ( spk->IsPackageUpdate() )
|
|
|
356 |
this->RadioTypeUpdate->Checked = true;
|
|
|
357 |
else if ( spk->IsPatch() )
|
|
|
358 |
this->RadioTypePatch->Checked = true;
|
|
|
359 |
else
|
|
|
360 |
{
|
|
|
361 |
this->RadioTypeScript->Checked = true;
|
|
|
362 |
this->ComboType->SelectedIndex = spk->GetScriptType();
|
|
|
363 |
this->ComboType->Enabled = true;
|
6 |
cycrow |
364 |
if ( this->ComboType->SelectedIndex == CSpkFile::SCRIPTTYPE_CUSTOM )
|
1 |
cycrow |
365 |
this->TextCustomType->Text = SystemStringFromCyString(spk->GetCustomScriptType(m_pP->GetLanguage()));
|
|
|
366 |
}
|
|
|
367 |
|
|
|
368 |
this->CheckOther->Checked = spk->IsAnotherMod();
|
|
|
369 |
this->TextOtherAuthor->Enabled = this->CheckOther->Checked;
|
|
|
370 |
this->TextOtherName->Enabled = this->CheckOther->Checked;
|
|
|
371 |
this->ButFromFile->Enabled = this->CheckOther->Checked;
|
|
|
372 |
|
|
|
373 |
if ( spk->IsAnotherMod() )
|
|
|
374 |
{
|
|
|
375 |
this->TextOtherAuthor->Text = SystemStringFromCyString(spk->GetOtherAuthor());
|
|
|
376 |
this->TextOtherName->Text = SystemStringFromCyString(spk->GetOtherName());
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
this->UpdateWares();
|
|
|
380 |
this->UpdateScriptType();
|
|
|
381 |
}
|
|
|
382 |
|
|
|
383 |
if ( !m_pPackage->GetCreationDate().Empty() )
|
|
|
384 |
{
|
|
|
385 |
CyString date = m_pPackage->GetCreationDate();
|
|
|
386 |
int day = m_pPackage->GetCreationDate().GetToken("/", 1, 1).ToInt();
|
|
|
387 |
int month = m_pPackage->GetCreationDate().GetToken("/", 2, 2).ToInt();
|
|
|
388 |
int year = m_pPackage->GetCreationDate().GetToken("/", 3, 3).ToInt();
|
|
|
389 |
if ( month > 12 && day <= 12 ) { int temp = day; day = month; month = temp; }
|
|
|
390 |
if ( month < 1 ) month = 1;
|
|
|
391 |
if ( month > 12 ) month = 12;
|
|
|
392 |
if ( day < 1 ) day = 1;
|
|
|
393 |
if ( day > 31 ) day = 1;
|
|
|
394 |
if ( year < 1900 ) year += 2000;
|
|
|
395 |
try {
|
|
|
396 |
this->CreationDate->Value = DateTime(year, month, day);
|
|
|
397 |
} catch(System::ArgumentOutOfRangeException ^) {
|
|
|
398 |
this->CreationDate->Value = DateTime::Today;
|
|
|
399 |
}
|
|
|
400 |
}
|
|
|
401 |
else
|
|
|
402 |
this->CreationDate->Value = DateTime::Today;
|
|
|
403 |
|
|
|
404 |
this->TextForum->Text = SystemStringFromCyString(m_pPackage->GetForumLink());
|
|
|
405 |
this->TextEmail->Text = SystemStringFromCyString(m_pPackage->GetEmail());
|
|
|
406 |
this->TextWebsite->Text = SystemStringFromCyString(m_pPackage->GetWebSite());
|
|
|
407 |
this->TextWebAddress->Text = SystemStringFromCyString(m_pPackage->GetWebAddress());
|
|
|
408 |
|
|
|
409 |
this->UpdateGamesList();
|
|
|
410 |
this->UpdateFileList();
|
|
|
411 |
this->UpdateMirrors();
|
|
|
412 |
this->UpdatePackageNames();
|
|
|
413 |
|
|
|
414 |
m_bSortingAsc = true;
|
|
|
415 |
m_iSortingCol = 1;
|
|
|
416 |
this->ListFiles->ListViewItemSorter = gcnew ListViewItemComparer(m_iSortingCol, !m_bSortingAsc);
|
|
|
417 |
|
|
|
418 |
this->UpdateDisplayPic();
|
|
|
419 |
this->UpdateDisplayIcon();
|
|
|
420 |
this->UpdateRatings();
|
|
|
421 |
this->UpdateText();
|
|
|
422 |
this->UpdateDependacies();
|
|
|
423 |
|
|
|
424 |
// delete the pages
|
|
|
425 |
if ( m_pPackage->GetType() != TYPE_XSP )
|
|
|
426 |
{
|
|
|
427 |
delete this->PageShip;
|
|
|
428 |
delete this->PageRaw;
|
|
|
429 |
delete this->PageShipComp;
|
|
|
430 |
this->PageShip = nullptr;
|
|
|
431 |
this->PageRaw = nullptr;
|
|
|
432 |
this->PageShipComp = nullptr;
|
|
|
433 |
this->PanelShip->Hide();
|
|
|
434 |
this->ToolCustomise->Visible = false;
|
|
|
435 |
}
|
|
|
436 |
else if ( m_pPackage->GetType() != TYPE_SPK )
|
|
|
437 |
{
|
|
|
438 |
delete this->PagePackage;
|
|
|
439 |
delete this->PageWares;
|
|
|
440 |
this->PageWares = nullptr;
|
|
|
441 |
this->PagePackage = nullptr;
|
|
|
442 |
}
|
|
|
443 |
|
|
|
444 |
m_bLoading = false;
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
void PackageForm::UpdateDependacies()
|
|
|
448 |
{
|
|
|
449 |
this->ListDep->Items->Clear();
|
|
|
450 |
for ( SNeededLibrary *nl = m_pPackage->GetNeededLibraries()->First(); nl; nl = m_pPackage->GetNeededLibraries()->Next() )
|
|
|
451 |
{
|
|
|
452 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(nl->sName));
|
|
|
453 |
item->SubItems->Add(SystemStringFromCyString(nl->sAuthor));
|
|
|
454 |
item->SubItems->Add(SystemStringFromCyString(nl->sMinVersion));
|
|
|
455 |
item->ImageIndex = 3;
|
|
|
456 |
this->ListDep->Items->Add(item);
|
|
|
457 |
}
|
|
|
458 |
this->ListDep->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
void PackageForm::UpdateShipPartList()
|
|
|
462 |
{
|
|
|
463 |
if ( !m_pPackage )
|
|
|
464 |
return;
|
|
|
465 |
CXspFile *xsp = (CXspFile *)m_pPackage;
|
|
|
466 |
|
|
|
467 |
// first lets adjust out columns
|
|
|
468 |
int numColums = 1;
|
|
|
469 |
this->ListShipPart->Visible = true;
|
|
|
470 |
this->ListShipPart->Items->Clear();
|
|
|
471 |
switch ( this->ComboShipPart->SelectedIndex )
|
|
|
472 |
{
|
|
|
473 |
case 0: // componants
|
|
|
474 |
numColums = 3;
|
|
|
475 |
this->ColumnPart1->Text = "Section";
|
|
|
476 |
this->ColumnPart2->Text = "ID";
|
|
|
477 |
this->ColumnPart3->Text = "Data";
|
|
|
478 |
for ( SComponent *c = xsp->GetComponents()->First(); c; c = xsp->GetComponents()->Next() )
|
|
|
479 |
{
|
|
|
480 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(c->sSection));
|
|
|
481 |
item->ImageKey = "components";
|
|
|
482 |
item->SubItems->Add(SystemStringFromCyString(c->sSection2));
|
|
|
483 |
item->SubItems->Add(SystemStringFromCyString(c->sData));
|
|
|
484 |
this->ListShipPart->Items->Add(item);
|
|
|
485 |
}
|
|
|
486 |
break;
|
|
|
487 |
case 1: // dummies
|
|
|
488 |
numColums = 2;
|
|
|
489 |
this->ColumnPart1->Text = "Section";
|
|
|
490 |
this->ColumnPart2->Text = "Data";
|
|
|
491 |
for ( SDummy *d = xsp->GetDummies()->First(); d; d = xsp->GetDummies()->Next() )
|
|
|
492 |
{
|
|
|
493 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(d->sSection));
|
|
|
494 |
item->SubItems->Add(SystemStringFromCyString(d->sData));
|
|
|
495 |
item->ImageKey = "dummies";
|
|
|
496 |
this->ListShipPart->Items->Add(item);
|
|
|
497 |
}
|
|
|
498 |
break;
|
|
|
499 |
case 2: // Cockpit
|
|
|
500 |
numColums = 3;
|
|
|
501 |
this->ColumnPart1->Text = "ID";
|
|
|
502 |
this->ColumnPart2->Text = "Index";
|
|
|
503 |
this->ColumnPart3->Text = "Data";
|
|
|
504 |
for ( SCockpit *c = xsp->GetCockpits()->First(); c; c = xsp->GetCockpits()->Next() )
|
|
|
505 |
{
|
|
|
506 |
CyString cName = c->sCockpit;
|
|
|
507 |
cName = cName.GetToken(";", -2);
|
|
|
508 |
while ( cName.Right(1) == ";" )
|
|
|
509 |
cName.Truncate(-1);
|
|
|
510 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(cName));
|
|
|
511 |
if ( c->iIndex == -1 )
|
|
|
512 |
item->SubItems->Add("<PACKAGE>");
|
|
|
513 |
else
|
|
|
514 |
item->SubItems->Add(Convert::ToString(c->iIndex));
|
|
|
515 |
item->SubItems->Add(SystemStringFromCyString(c->sCockpit));
|
|
|
516 |
item->ImageKey = "cockpit";
|
|
|
517 |
this->ListShipPart->Items->Add(item);
|
|
|
518 |
}
|
|
|
519 |
break;
|
|
|
520 |
case 3: // CutData
|
|
|
521 |
numColums = 1;
|
|
|
522 |
this->ColumnPart1->Text = "Cuts";
|
|
|
523 |
for ( SStringList *cut = xsp->GetCutData()->Head(); cut; cut = cut->next )
|
|
|
524 |
{
|
|
|
525 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(cut->str));
|
|
|
526 |
item->ImageKey = "cutdata";
|
|
|
527 |
this->ListShipPart->Items->Add(item);
|
|
|
528 |
}
|
|
|
529 |
break;
|
|
|
530 |
case 4: // Bodies
|
|
|
531 |
numColums = 2;
|
|
|
532 |
this->ColumnPart1->Text = "Section";
|
|
|
533 |
this->ColumnPart2->Text = "Bodies";
|
|
|
534 |
for ( SStringList *b = xsp->GetBodies()->Head(); b; b = b->next )
|
|
|
535 |
{
|
|
|
536 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(b->str.GetToken(";", 1, 1)));
|
|
|
537 |
item->SubItems->Add(SystemStringFromCyString(b->str.GetToken(";", 2)));
|
|
|
538 |
item->ImageKey = "bodies";
|
|
|
539 |
this->ListShipPart->Items->Add(item);
|
|
|
540 |
}
|
|
|
541 |
break;
|
|
|
542 |
case 5: // Animations
|
|
|
543 |
numColums = 1;
|
|
|
544 |
this->ColumnPart1->Text = "Animations";
|
|
|
545 |
for ( SStringList *a = xsp->GetAnimations()->Head(); a; a = a->next )
|
|
|
546 |
{
|
|
|
547 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(a->str));
|
|
|
548 |
item->ImageKey = "animations";
|
|
|
549 |
this->ListShipPart->Items->Add(item);
|
|
|
550 |
}
|
|
|
551 |
break;
|
|
|
552 |
|
|
|
553 |
// dont know what we are supposed to be displaying
|
|
|
554 |
default:
|
|
|
555 |
this->ListShipPart->Visible = false;
|
|
|
556 |
}
|
|
|
557 |
|
|
|
558 |
this->ListShipPart->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
559 |
// adjust size of columns
|
|
|
560 |
if ( numColums < 3 )
|
|
|
561 |
this->ColumnPart3->Width = 0;
|
|
|
562 |
if ( numColums < 2 )
|
|
|
563 |
this->ColumnPart2->Width = 0;
|
|
|
564 |
}
|
|
|
565 |
|
|
|
566 |
void PackageForm::UpdateShipText()
|
|
|
567 |
{
|
|
|
568 |
CXspFile *xsp = (CXspFile *)m_pPackage;
|
|
|
569 |
|
|
|
570 |
this->ListShipText->Items->Clear();
|
|
|
571 |
|
|
|
572 |
for ( SText *t = xsp->GetTexts()->First(); t; t = xsp->GetTexts()->Next() )
|
|
|
573 |
{
|
|
|
574 |
ListViewItem ^item = gcnew ListViewItem(System::Convert::ToString(t->iId));
|
|
|
575 |
item->ImageIndex = 0;
|
|
|
576 |
item->SubItems->Add(SystemStringFromCyString(t->sName));
|
|
|
577 |
item->SubItems->Add(SystemStringFromCyString(t->sDesc));
|
|
|
578 |
this->ListShipText->Items->Add(item);
|
|
|
579 |
}
|
|
|
580 |
|
|
|
581 |
this->ListShipText->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
582 |
}
|
|
|
583 |
|
|
|
584 |
void PackageForm::UpdateDisplayPic()
|
|
|
585 |
{
|
|
|
586 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(PackageForm::typeid));
|
|
|
587 |
this->ButPicBack->Enabled = false;
|
|
|
588 |
this->ButPicNext->Enabled = false;
|
|
|
589 |
if ( m_pDisplayFile )
|
|
|
590 |
{
|
|
|
591 |
CyString filePointer = m_pDisplayFile->GetFilePointer();
|
|
|
592 |
filePointer = filePointer.FindReplace("/", "\\");
|
|
|
593 |
filePointer = filePointer.FindReplace("\\\\", "\\");
|
|
|
594 |
if ( System::IO::File::Exists(SystemStringFromCyString(filePointer)) )
|
|
|
595 |
{
|
|
|
596 |
Bitmap ^myBitmap = gcnew Bitmap(SystemStringFromCyString(filePointer));
|
|
|
597 |
if ( myBitmap )
|
|
|
598 |
this->DisplayPicture->Image = dynamic_cast<Image ^>(myBitmap);
|
|
|
599 |
}
|
|
|
600 |
this->ButPicDel->Enabled = true;
|
|
|
601 |
|
|
|
602 |
if ( m_pPackage->GetFirstFile(FILETYPE_ADVERT) != m_pDisplayFile )
|
|
|
603 |
this->ButPicBack->Enabled = true;
|
|
|
604 |
if ( m_pPackage->GetNextFile(m_pDisplayFile) )
|
|
|
605 |
this->ButPicNext->Enabled = true;
|
|
|
606 |
}
|
|
|
607 |
else
|
|
|
608 |
{
|
|
|
609 |
this->ButPicDel->Enabled = false;
|
|
|
610 |
this->DisplayPicture->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"DisplayPicture.Image")));
|
|
|
611 |
}
|
|
|
612 |
|
|
|
613 |
}
|
|
|
614 |
|
|
|
615 |
void PackageForm::UpdateDisplayIcon()
|
|
|
616 |
{
|
|
|
617 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(PackageForm::typeid));
|
|
|
618 |
|
|
|
619 |
m_pTabPage->ImageIndex = 0;
|
|
|
620 |
|
|
|
621 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
622 |
this->DisplayIcon->Image = this->imageList1->Images[1];
|
|
|
623 |
else
|
|
|
624 |
{
|
|
|
625 |
this->DisplayIcon->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"DisplayIcon.Image")));
|
|
|
626 |
|
|
|
627 |
int num = -1;
|
|
|
628 |
if ( m_pPackage->GetType() == TYPE_SPK )
|
|
|
629 |
{
|
|
|
630 |
CSpkFile *spk = (CSpkFile *)m_pPackage;
|
|
|
631 |
if ( spk->IsLibrary() )
|
|
|
632 |
num = 3;
|
|
|
633 |
else if ( spk->IsPackageUpdate() )
|
|
|
634 |
num = 6;
|
|
|
635 |
else if ( spk->IsPatch() )
|
|
|
636 |
num = 7;
|
|
|
637 |
else if ( spk->IsCustomStart() )
|
|
|
638 |
num = 8;
|
|
|
639 |
}
|
|
|
640 |
|
|
|
641 |
if ( num == -1 && m_pPackage->IsFakePatch() )
|
|
|
642 |
num = 2;
|
|
|
643 |
|
|
|
644 |
if ( num != -1 )
|
|
|
645 |
{
|
|
|
646 |
this->DisplayIcon->Image = this->imageList1->Images[num];
|
|
|
647 |
m_pTabPage->ImageIndex = num;
|
|
|
648 |
}
|
|
|
649 |
}
|
|
|
650 |
|
|
|
651 |
this->ButIconDel->Enabled = false;
|
|
|
652 |
|
|
|
653 |
if ( m_pPackage->GetIcon() )
|
|
|
654 |
{
|
|
|
655 |
this->ButIconDel->Enabled = true;
|
|
|
656 |
CyString filePointer = m_pPackage->GetIcon()->GetFilePointer();
|
|
|
657 |
filePointer = filePointer.FindReplace("/", "\\");
|
|
|
658 |
filePointer = filePointer.FindReplace("\\\\", "\\");
|
|
|
659 |
String ^file = SystemStringFromCyString(filePointer);
|
|
|
660 |
if ( System::IO::File::Exists(file) )
|
|
|
661 |
{
|
|
|
662 |
Bitmap ^myBitmap = gcnew Bitmap(file);
|
|
|
663 |
if ( myBitmap )
|
|
|
664 |
{
|
|
|
665 |
this->DisplayIcon->Image = dynamic_cast<Image ^>(myBitmap);
|
|
|
666 |
this->imageList1->Images->Add(file, myBitmap);
|
|
|
667 |
m_pTabPage->ImageIndex = this->imageList1->Images->IndexOfKey(file);
|
|
|
668 |
if ( m_pTabPage->ImageIndex == -1 )
|
|
|
669 |
m_pTabPage->ImageIndex = 0;
|
|
|
670 |
}
|
|
|
671 |
}
|
|
|
672 |
}
|
|
|
673 |
|
|
|
674 |
if ( m_pTabPage->ImageIndex == 0 )
|
|
|
675 |
{
|
|
|
676 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
677 |
m_pTabPage->ImageIndex = 1;
|
|
|
678 |
}
|
|
|
679 |
|
|
|
680 |
m_pMenuItem->Image = this->imageList1->Images[m_pTabPage->ImageIndex];
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
void PackageForm::UpdateGameVersion()
|
|
|
684 |
{
|
|
|
685 |
bool restoreLoad = m_bLoading;
|
|
|
686 |
m_bLoading = true;
|
|
|
687 |
|
|
|
688 |
ComboVersion->BeginUpdate();
|
|
|
689 |
ComboVersion->Items->Clear();
|
|
|
690 |
|
|
|
691 |
this->TextExactVersion->Hide();
|
|
|
692 |
|
|
|
693 |
SGameExe *exe = NULL;
|
|
|
694 |
if ( ButGame->ImageIndex >= 0 )
|
|
|
695 |
exe = m_pP->GetGameExe()->GetGame((m_pPackage) ? ButGame->ImageIndex : -1);
|
|
|
696 |
if ( exe )
|
|
|
697 |
{
|
|
|
698 |
ComboVersion->Items->Add("Original");
|
|
|
699 |
for ( int i = 0; i < exe->lVersions.size(); i++ )
|
|
|
700 |
{
|
|
|
701 |
SGameExeVersion *v = exe->lVersions[i];
|
|
|
702 |
ComboVersion->Items->Add(SystemStringFromCyString(v->sName));
|
|
|
703 |
}
|
|
|
704 |
ComboVersion->Items->Add("Exact (Custom)");
|
|
|
705 |
ComboVersion->Enabled = true;
|
|
|
706 |
}
|
|
|
707 |
else
|
|
|
708 |
{
|
|
|
709 |
ComboVersion->Enabled = false;
|
|
|
710 |
}
|
|
|
711 |
|
|
|
712 |
|
|
|
713 |
ComboVersion->EndUpdate();
|
|
|
714 |
|
|
|
715 |
if ( !restoreLoad )
|
|
|
716 |
m_bLoading = false;
|
|
|
717 |
}
|
|
|
718 |
|
|
|
719 |
void PackageForm::UpdateRatings()
|
|
|
720 |
{
|
|
|
721 |
this->PicEase1->BackColor = System::Drawing::Color::Transparent;
|
|
|
722 |
this->PicEase2->BackColor = System::Drawing::Color::Transparent;
|
|
|
723 |
this->PicEase3->BackColor = System::Drawing::Color::Transparent;
|
|
|
724 |
this->PicEase4->BackColor = System::Drawing::Color::Transparent;
|
|
|
725 |
this->PicEase5->BackColor = System::Drawing::Color::Transparent;
|
|
|
726 |
|
|
|
727 |
this->PicChange1->BackColor = System::Drawing::Color::Transparent;
|
|
|
728 |
this->PicChange2->BackColor = System::Drawing::Color::Transparent;
|
|
|
729 |
this->PicChange3->BackColor = System::Drawing::Color::Transparent;
|
|
|
730 |
this->PicChange4->BackColor = System::Drawing::Color::Transparent;
|
|
|
731 |
this->PicChange5->BackColor = System::Drawing::Color::Transparent;
|
|
|
732 |
|
|
|
733 |
this->PicRec1->BackColor = System::Drawing::Color::Transparent;
|
|
|
734 |
this->PicRec2->BackColor = System::Drawing::Color::Transparent;
|
|
|
735 |
this->PicRec3->BackColor = System::Drawing::Color::Transparent;
|
|
|
736 |
this->PicRec4->BackColor = System::Drawing::Color::Transparent;
|
|
|
737 |
this->PicRec5->BackColor = System::Drawing::Color::Transparent;
|
|
|
738 |
|
|
|
739 |
if ( m_pPackage->GetEaseOfUse() >= 1 )
|
|
|
740 |
this->PicEase1->BackColor = System::Drawing::Color::Red;
|
|
|
741 |
if ( m_pPackage->GetEaseOfUse() >= 2 )
|
|
|
742 |
this->PicEase2->BackColor = System::Drawing::Color::Red;
|
|
|
743 |
if ( m_pPackage->GetEaseOfUse() >= 3 )
|
|
|
744 |
this->PicEase3->BackColor = System::Drawing::Color::Red;
|
|
|
745 |
if ( m_pPackage->GetEaseOfUse() >= 4 )
|
|
|
746 |
this->PicEase4->BackColor = System::Drawing::Color::Red;
|
|
|
747 |
if ( m_pPackage->GetEaseOfUse() >= 5 )
|
|
|
748 |
this->PicEase5->BackColor = System::Drawing::Color::Red;
|
|
|
749 |
|
|
|
750 |
if ( m_pPackage->GetRecommended() >= 1 )
|
|
|
751 |
this->PicRec1->BackColor = System::Drawing::Color::Red;
|
|
|
752 |
if ( m_pPackage->GetRecommended() >= 2 )
|
|
|
753 |
this->PicRec2->BackColor = System::Drawing::Color::Red;
|
|
|
754 |
if ( m_pPackage->GetRecommended() >= 3 )
|
|
|
755 |
this->PicRec3->BackColor = System::Drawing::Color::Red;
|
|
|
756 |
if ( m_pPackage->GetRecommended() >= 4 )
|
|
|
757 |
this->PicRec4->BackColor = System::Drawing::Color::Red;
|
|
|
758 |
if ( m_pPackage->GetRecommended() >= 5 )
|
|
|
759 |
this->PicRec5->BackColor = System::Drawing::Color::Red;
|
|
|
760 |
|
|
|
761 |
if ( m_pPackage->GetGameChanging() >= 1 )
|
|
|
762 |
this->PicChange1->BackColor = System::Drawing::Color::Red;
|
|
|
763 |
if ( m_pPackage->GetGameChanging() >= 2 )
|
|
|
764 |
this->PicChange2->BackColor = System::Drawing::Color::Red;
|
|
|
765 |
if ( m_pPackage->GetGameChanging() >= 3 )
|
|
|
766 |
this->PicChange3->BackColor = System::Drawing::Color::Red;
|
|
|
767 |
if ( m_pPackage->GetGameChanging() >= 4 )
|
|
|
768 |
this->PicChange4->BackColor = System::Drawing::Color::Red;
|
|
|
769 |
if ( m_pPackage->GetGameChanging() >= 5 )
|
|
|
770 |
this->PicChange5->BackColor = System::Drawing::Color::Red;
|
|
|
771 |
|
|
|
772 |
if ( m_pPackage->GetEaseOfUse() < 0 )
|
|
|
773 |
this->GroupEase->Text = "Ease of Use";
|
|
|
774 |
else
|
|
|
775 |
this->GroupEase->Text = "Ease of Use (" + System::Convert::ToString(m_pPackage->GetEaseOfUse()) + ")";
|
|
|
776 |
|
|
|
777 |
if ( m_pPackage->GetGameChanging() < 0 )
|
|
|
778 |
this->GroupChange->Text = "Game Changing";
|
|
|
779 |
else
|
|
|
780 |
this->GroupChange->Text = "Game Changing (" + System::Convert::ToString(m_pPackage->GetGameChanging()) + ")";
|
|
|
781 |
|
|
|
782 |
if ( m_pPackage->GetRecommended() < 0 )
|
|
|
783 |
this->GroupRec->Text = "Recommended";
|
|
|
784 |
else
|
|
|
785 |
this->GroupRec->Text = "Recommended (" + System::Convert::ToString(m_pPackage->GetRecommended()) + ")";
|
|
|
786 |
}
|
|
|
787 |
|
|
|
788 |
void PackageForm::Setup()
|
|
|
789 |
{
|
|
|
790 |
m_bLoading = true;
|
|
|
791 |
|
|
|
792 |
this->ComboFileType->Items->Add("All Files");
|
|
|
793 |
for ( int i = 0; i < FILETYPE_MAX; i++ )
|
|
|
794 |
this->ComboFileType->Items->Add(SystemStringFromCyString(GetFileTypeString(i)));
|
|
|
795 |
this->ComboFileType->SelectedIndex = 0;
|
|
|
796 |
|
|
|
797 |
this->PanelShip->Hide();
|
|
|
798 |
|
|
|
799 |
m_bSortingAsc = true;
|
|
|
800 |
m_iSortingCol = 1;
|
|
|
801 |
|
|
|
802 |
this->ListFiles->ColumnClick += gcnew ColumnClickEventHandler(this, &Creator::PackageForm::SortList);
|
|
|
803 |
this->ListFiles->ItemChecked += gcnew ItemCheckedEventHandler(this, &PackageForm::Event_FileChecked);
|
|
|
804 |
|
|
|
805 |
this->ContextGames->Items->Clear();
|
|
|
806 |
|
|
|
807 |
this->ComboGameFilter->Items->Clear();
|
|
|
808 |
this->ToolGame->DropDownItems->Clear();
|
|
|
809 |
|
|
|
810 |
this->ComboGameFilter->Items->Add("- None -");
|
|
|
811 |
this->ComboGameFilter->Items->Add("- All Games -");
|
|
|
812 |
|
|
|
813 |
for ( int i = 0; i < m_pP->GetGameExe()->GetNumGames(); i++ )
|
|
|
814 |
{
|
|
|
815 |
SGameExe *gameExe = m_pP->GetGameExe()->GetGame(i);
|
|
|
816 |
if ( gameExe )
|
|
|
817 |
{
|
|
|
818 |
System::Windows::Forms::ToolStripMenuItem ^newItem = gcnew System::Windows::Forms::ToolStripMenuItem;
|
|
|
819 |
newItem->Text = SystemStringFromCyString(gameExe->sName);
|
|
|
820 |
newItem->Tag = Convert::ToString(i + 1);
|
|
|
821 |
newItem->Image = this->imageListGames->Images[i];
|
|
|
822 |
newItem->Click += gcnew System::EventHandler(this, &PackageForm::ContextGame_Selected);
|
|
|
823 |
this->ContextGames->Items->Add(newItem);
|
|
|
824 |
|
|
|
825 |
System::Windows::Forms::ToolStripMenuItem ^newItem2 = gcnew System::Windows::Forms::ToolStripMenuItem;
|
|
|
826 |
newItem2->Text = SystemStringFromCyString(gameExe->sName);
|
|
|
827 |
newItem2->Tag = Convert::ToString(i + 1);
|
|
|
828 |
newItem2->Image = this->imageListGames->Images[i];
|
|
|
829 |
newItem2->Click += gcnew System::EventHandler(this, &PackageForm::SetGame_Selected);
|
|
|
830 |
this->ToolGame->DropDownItems->Add(newItem2);
|
|
|
831 |
|
|
|
832 |
this->ComboGameFilter->Items->Add(SystemStringFromCyString(gameExe->sName));
|
|
|
833 |
}
|
|
|
834 |
}
|
|
|
835 |
|
|
|
836 |
this->ComboGameFilter->SelectedIndex = 0;
|
|
|
837 |
|
|
|
838 |
this->ButGame->Text = "- Select Game -";
|
|
|
839 |
this->ButGameAdd->Enabled = false;
|
|
|
840 |
|
|
|
841 |
m_pTypeList->Clear();
|
6 |
cycrow |
842 |
for ( int i = 0; i < CSpkFile::SCRIPTTYPE_MAX; i++ )
|
1 |
cycrow |
843 |
{
|
10 |
cycrow |
844 |
m_pTypeList->PushBack(CSpkFile::GetScriptTypeStringStatic(i).c_str());
|
1 |
cycrow |
845 |
ComboType->Items->Add(SystemStringFromCyString(CSpkFile::GetScriptTypeStringStatic(i)));
|
|
|
846 |
}
|
|
|
847 |
|
|
|
848 |
this->CreationDate->Value = DateTime::Today;
|
|
|
849 |
|
|
|
850 |
m_bLoading = false;
|
|
|
851 |
}
|
|
|
852 |
|
|
|
853 |
void PackageForm::UpdateGamesList()
|
|
|
854 |
{
|
|
|
855 |
this->ListGames->Items->Clear();
|
|
|
856 |
for ( SGameCompat *game = m_pPackage->GetGameCompatabilityList()->First(); game; game = m_pPackage->GetGameCompatabilityList()->Next() ) {
|
|
|
857 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(m_pP->GetGameNameFromType(game->iGame)));
|
|
|
858 |
item->ImageIndex = (game->iGame < 0) ? -1 : (game->iGame - 1);
|
|
|
859 |
if ( !game->sVersion.Empty() ) {
|
|
|
860 |
item->SubItems->Add("Exact: " + SystemStringFromCyString(game->sVersion));
|
|
|
861 |
}
|
|
|
862 |
else {
|
|
|
863 |
item->SubItems->Add(SystemStringFromCyString(m_pP->GetGameVersionFromType(game->iGame, game->iVersion, game->sVersion)));
|
|
|
864 |
}
|
|
|
865 |
item->Tag = game->iGame;
|
|
|
866 |
this->ListGames->Items->Add(item);
|
|
|
867 |
}
|
|
|
868 |
|
|
|
869 |
this->ListGames->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
870 |
}
|
|
|
871 |
|
|
|
872 |
void PackageForm::UpdateFileList()
|
|
|
873 |
{
|
|
|
874 |
this->ButRemoveFile->Enabled = false;
|
|
|
875 |
|
|
|
876 |
int pos = 0;
|
|
|
877 |
this->ListFiles->Items->Clear();
|
|
|
878 |
if ( m_pPackage ) {
|
|
|
879 |
for ( C_File *file = m_pPackage->GetFileList()->First(); file; file = m_pPackage->GetFileList()->Next() )
|
|
|
880 |
{
|
|
|
881 |
file->SetPos(pos++);
|
|
|
882 |
if ( this->ComboGameFilter->SelectedIndex > 0 ) {
|
|
|
883 |
if ( this->ComboGameFilter->SelectedIndex - 1 != file->GetGame() )
|
|
|
884 |
continue;
|
|
|
885 |
}
|
|
|
886 |
if ( this->ComboFileType->SelectedIndex == 0 || (this->ComboFileType->SelectedIndex - 1) == file->GetFileType() )
|
|
|
887 |
this->AddFile(file);
|
|
|
888 |
}
|
|
|
889 |
((Form1 ^)this->MdiParent)->UpdateStatus();
|
|
|
890 |
}
|
|
|
891 |
|
|
|
892 |
this->ListFiles->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
893 |
}
|
|
|
894 |
|
|
|
895 |
void PackageForm::AddFile(C_File *file)
|
|
|
896 |
{
|
|
|
897 |
ListViewItem ^item = gcnew ListViewItem("");
|
|
|
898 |
|
|
|
899 |
if ( file->GetData() )
|
|
|
900 |
{
|
|
|
901 |
item->SubItems->Add(SystemStringFromCyString(CyString("<PACKAGE>/") + file->GetNameDirectory(NULL)));
|
|
|
902 |
item->SubItems->Add(SystemStringFromCyString(file->GetUncompressedSizeString()));
|
|
|
903 |
}
|
|
|
904 |
else
|
|
|
905 |
{
|
|
|
906 |
item->SubItems->Add(SystemStringFromCyString(file->GetFullFilename()));
|
|
|
907 |
item->SubItems->Add(SystemStringFromCyString(SPK::GetSizeString(file->GetSize())));
|
|
|
908 |
}
|
|
|
909 |
|
|
|
910 |
if ( file->IsFakePatch() )
|
|
|
911 |
item->SubItems->Add("Mod (Fakepatch)");
|
|
|
912 |
else
|
|
|
913 |
item->SubItems->Add(SystemStringFromCyString(file->GetFileTypeString()));
|
|
|
914 |
|
|
|
915 |
if ( !file->GetDir().Empty() )
|
|
|
916 |
item->SubItems->Add(SystemStringFromCyString(file->GetDir()));
|
|
|
917 |
else
|
|
|
918 |
item->SubItems->Add("");
|
|
|
919 |
|
|
|
920 |
if ( file->IsSigned() )
|
|
|
921 |
item->SubItems->Add("Yes");
|
|
|
922 |
else
|
|
|
923 |
item->SubItems->Add("No");
|
|
|
924 |
|
|
|
925 |
if ( !file->GetGame() )
|
|
|
926 |
item->SubItems->Add("All Games");
|
|
|
927 |
else {
|
|
|
928 |
CPackages p;
|
|
|
929 |
p.Startup(".", ".", ".");
|
|
|
930 |
SGameExe *exe = p.GetGameExe()->GetGame(file->GetGame() - 1);
|
|
|
931 |
if ( exe ) {
|
|
|
932 |
item->SubItems->Add(SystemStringFromCyString(exe->sName));
|
|
|
933 |
}
|
|
|
934 |
else {
|
|
|
935 |
item->SubItems->Add("Game: " + file->GetGame());
|
|
|
936 |
}
|
|
|
937 |
}
|
|
|
938 |
|
|
|
939 |
item->Tag = SystemStringFromCyString(CyString::Number(file->GetPos()));
|
|
|
940 |
if ( file->IsFakePatch() )
|
|
|
941 |
item->ImageKey = "fakepatch";
|
|
|
942 |
else
|
|
|
943 |
item->ImageIndex = file->GetFileType();
|
|
|
944 |
|
|
|
945 |
item->Checked = file->IsShared();
|
|
|
946 |
|
|
|
947 |
this->ListFiles->Items->Add(item);
|
|
|
948 |
}
|
|
|
949 |
|
|
|
950 |
void PackageForm::AddNewFile()
|
|
|
951 |
{
|
|
|
952 |
// add filters
|
|
|
953 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
954 |
|
|
|
955 |
System::String ^filter;
|
|
|
956 |
for ( int i = 0; i < FILETYPE_MAX; i++ )
|
|
|
957 |
{
|
|
|
958 |
if ( filter )
|
|
|
959 |
filter += "|";
|
|
|
960 |
filter += SystemStringFromCyString(GetFileTypeString(i));
|
|
|
961 |
filter += "|";
|
|
|
962 |
// add extensions
|
|
|
963 |
switch ( i )
|
|
|
964 |
{
|
|
|
965 |
case FILETYPE_SCRIPT:
|
|
|
966 |
case FILETYPE_UNINSTALL:
|
|
|
967 |
case FILETYPE_MAP:
|
|
|
968 |
case FILETYPE_TEXT:
|
|
|
969 |
case FILETYPE_MISSION:
|
|
|
970 |
filter += "*.pck;*.xml";
|
|
|
971 |
break;
|
|
|
972 |
|
|
|
973 |
case FILETYPE_README:
|
|
|
974 |
filter += "*.txt;*.doc;*.docx;*.pdf";
|
|
|
975 |
break;
|
|
|
976 |
|
|
|
977 |
case FILETYPE_MOD:
|
|
|
978 |
filter += "*.cat";
|
|
|
979 |
break;
|
|
|
980 |
|
|
|
981 |
case FILETYPE_SOUND:
|
|
|
982 |
filter += "*.wav";
|
|
|
983 |
break;
|
|
|
984 |
|
|
|
985 |
case FILETYPE_SCREEN:
|
|
|
986 |
case FILETYPE_ADVERT:
|
|
|
987 |
filter += "*.jpg;*.png";
|
|
|
988 |
break;
|
|
|
989 |
|
|
|
990 |
case FILETYPE_SHIPSCENE:
|
|
|
991 |
case FILETYPE_COCKPITSCENE:
|
|
|
992 |
filter += "*.pbd;*.bod";
|
|
|
993 |
break;
|
|
|
994 |
|
|
|
995 |
case FILETYPE_SHIPMODEL:
|
|
|
996 |
filter += "*.pbd;*.bod;*.bob;*.pbb";
|
|
|
997 |
break;
|
|
|
998 |
|
|
|
999 |
default:
|
|
|
1000 |
filter += "*.*";
|
|
|
1001 |
}
|
|
|
1002 |
}
|
|
|
1003 |
ofd->Filter = filter;
|
|
|
1004 |
ofd->FilterIndex = 1;
|
|
|
1005 |
ofd->RestoreDirectory = true;
|
|
|
1006 |
ofd->Multiselect = true;
|
|
|
1007 |
ofd->Title = "Select File(s) to add to package";
|
|
|
1008 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1009 |
{
|
|
|
1010 |
CyString dir;
|
|
|
1011 |
if ( C_File::DoesTypeHaveExtraDir(ofd->FilterIndex - 1) )
|
|
|
1012 |
{
|
|
|
1013 |
InputBox ^input = gcnew InputBox("Enter the directory to add files to", ((ofd->FilterIndex - 1) == FILETYPE_EXTRA) ? "PluginManager/Extras/$scriptname" : "");
|
|
|
1014 |
if ( input->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1015 |
dir = CyStringFromSystemString(input->GetInput());
|
|
|
1016 |
}
|
|
|
1017 |
array<System::String ^> ^fileArray = ofd->FileNames;
|
|
|
1018 |
for ( int i = 0; i < fileArray->Length; i++ )
|
|
|
1019 |
{
|
|
|
1020 |
System::String ^file = fileArray[i];
|
|
|
1021 |
int filetype = m_pP->AdjustFileType(CyStringFromSystemString(file), ofd->FilterIndex - 1);
|
|
|
1022 |
C_File *f = m_pPackage->AddFile(CyStringFromSystemString(file), dir, filetype);
|
|
|
1023 |
if ( (ofd->FilterIndex - 1) == FILETYPE_MOD )
|
|
|
1024 |
m_pPackage->AddFile(CFileIO(CyStringFromSystemString(file)).ChangeFileExtension("dat"), dir, filetype);
|
|
|
1025 |
}
|
|
|
1026 |
m_pPackage->UpdateSigned(false);
|
|
|
1027 |
this->UpdateFileList();
|
|
|
1028 |
this->UpdateDisplayPic();
|
|
|
1029 |
this->UpdateChanged();
|
|
|
1030 |
}
|
|
|
1031 |
}
|
|
|
1032 |
|
|
|
1033 |
bool PackageForm::CheckSave()
|
|
|
1034 |
{
|
|
|
1035 |
if ( m_pPackage->GetName().Empty() )
|
|
|
1036 |
{
|
|
|
1037 |
MessageBox::Show(this, "You must specify a package name", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1038 |
return false;
|
|
|
1039 |
}
|
|
|
1040 |
if ( m_pPackage->GetAuthor().Empty() )
|
|
|
1041 |
{
|
|
|
1042 |
MessageBox::Show(this, "You must specify an Author", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1043 |
return false;
|
|
|
1044 |
}
|
|
|
1045 |
if ( m_pPackage->GetVersion().Empty() )
|
|
|
1046 |
{
|
|
|
1047 |
MessageBox::Show(this, "You must specify a version number", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1048 |
return false;
|
|
|
1049 |
}
|
|
|
1050 |
|
|
|
1051 |
if ( m_pPackage->GetType() == TYPE_SPK )
|
|
|
1052 |
{
|
|
|
1053 |
if ( ((CSpkFile *)m_pPackage)->IsPackageUpdate() )
|
|
|
1054 |
{
|
|
|
1055 |
SNeededLibrary *n = m_pPackage->FindPackageNeeded("<package>", "<author>");
|
|
|
1056 |
if ( !n )
|
|
|
1057 |
m_pPackage->AddNeededLibrary("<package>", "<author>", "1.00");
|
|
|
1058 |
n = m_pPackage->FindPackageNeeded("<package>", "<author>");
|
|
|
1059 |
|
|
|
1060 |
if ( n )
|
|
|
1061 |
{
|
|
|
1062 |
if ( ((CSpkFile *)m_pPackage)->GetVersion().CompareVersion(n->sMinVersion) != COMPARE_OLDER )
|
|
|
1063 |
{
|
|
|
1064 |
MessageBox::Show(this, "The depencay vesion (" + SystemStringFromCyString(n->sMinVersion) + ") is too high, it must be lower than the current version (" + SystemStringFromCyString(m_pPackage->GetVersion()) + ")", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1065 |
return false;
|
|
|
1066 |
}
|
|
|
1067 |
}
|
|
|
1068 |
}
|
|
|
1069 |
else if ( ((CSpkFile *)m_pPackage)->IsCustomStart() )
|
|
|
1070 |
{
|
|
|
1071 |
if ( !((CSpkFile *)m_pPackage)->CheckValidCustomStart() )
|
|
|
1072 |
{
|
|
|
1073 |
MessageBox::Show(this, "For a custom start, you must include an initplayer script", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1074 |
return false;
|
|
|
1075 |
}
|
|
|
1076 |
}
|
|
|
1077 |
else if ( ((CSpkFile *)m_pPackage)->IsPatch() )
|
|
|
1078 |
{
|
10 |
cycrow |
1079 |
if ( ((CSpkFile *)m_pPackage)->GetOtherAuthor().empty() || ((CSpkFile *)m_pPackage)->GetOtherName().empty() )
|
1 |
cycrow |
1080 |
{
|
|
|
1081 |
MessageBox::Show(this, "For a mod patch, you must specify the parent mod that this will be patching\nEnter the parent mod name and author", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1082 |
return false;
|
|
|
1083 |
}
|
|
|
1084 |
}
|
|
|
1085 |
}
|
|
|
1086 |
|
|
|
1087 |
System::DateTime ^time = DateTime(this->CreationDate->Value);
|
|
|
1088 |
|
|
|
1089 |
String ^t = System::Convert::ToString(time->Day) + "/" + System::Convert::ToString(time->Month) + "/" + System::Convert::ToString(time->Year);
|
|
|
1090 |
m_pPackage->SetCreationDate(CyStringFromSystemString(t));
|
|
|
1091 |
|
|
|
1092 |
return true;
|
|
|
1093 |
}
|
|
|
1094 |
|
|
|
1095 |
void PackageForm::Save()
|
|
|
1096 |
{
|
|
|
1097 |
if ( !this->CheckSave() )
|
|
|
1098 |
return;
|
|
|
1099 |
|
|
|
1100 |
if ( m_pPackage->GetFilename().Empty() )
|
|
|
1101 |
{
|
|
|
1102 |
this->SaveAs();
|
|
|
1103 |
return;
|
|
|
1104 |
}
|
|
|
1105 |
|
|
|
1106 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
1107 |
((CXspFile *)m_pPackage)->AdjustCockpits();
|
|
|
1108 |
|
|
|
1109 |
SaveDialog ^save = gcnew SaveDialog(m_pPackage, SystemStringFromCyString(m_pPackage->GetFilename()));
|
|
|
1110 |
if ( save->ShowDialog(this) == Windows::Forms::DialogResult::Cancel )
|
|
|
1111 |
return;
|
|
|
1112 |
|
|
|
1113 |
this->UpdateFileList();
|
|
|
1114 |
m_pPackage->SetChanged(false);
|
|
|
1115 |
this->UpdateChanged();
|
|
|
1116 |
|
|
|
1117 |
if ( m_pSettings->bGenerateUpdate )
|
|
|
1118 |
m_pPackage->CreateUpdateFile(CFileIO(m_pPackage->GetFilename()).GetDir());
|
|
|
1119 |
|
|
|
1120 |
MessageBox::Show("Package: " + SystemStringFromCyString(m_pPackage->GetFilename()) + "\nHas been saved!", "Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
|
|
1121 |
}
|
|
|
1122 |
|
|
|
1123 |
void PackageForm::SaveAs()
|
|
|
1124 |
{
|
|
|
1125 |
if ( !this->CheckSave() )
|
|
|
1126 |
return;
|
|
|
1127 |
|
|
|
1128 |
SaveFileDialog ^ofd = gcnew SaveFileDialog();
|
|
|
1129 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
1130 |
ofd->Filter = "Ship Files (*.xsp)|*.xsp";
|
|
|
1131 |
else
|
|
|
1132 |
ofd->Filter = "Package Files (*.spk)|*.spk";
|
|
|
1133 |
ofd->AddExtension = true;
|
|
|
1134 |
CyString filename = m_pPackage->GetFilename();
|
|
|
1135 |
if ( filename.Empty() )
|
|
|
1136 |
filename = m_pPackage->GetAutosaveName();
|
|
|
1137 |
filename = filename.FindReplace("/", "\\");
|
|
|
1138 |
ofd->FileName = SystemStringFromCyString(filename);
|
|
|
1139 |
ofd->FilterIndex = 1;
|
|
|
1140 |
ofd->RestoreDirectory = true;
|
|
|
1141 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1142 |
{
|
|
|
1143 |
m_pPackage->SetFilename(CyStringFromSystemString(ofd->FileName));
|
|
|
1144 |
m_sFilename = ofd->FileName;
|
|
|
1145 |
m_pTabPage->Text = SystemStringFromCyString(CFileIO(m_pPackage->GetFilename()).GetFilename());
|
|
|
1146 |
m_pMenuItem->Text = m_pTabPage->Text;
|
|
|
1147 |
this->Save();
|
|
|
1148 |
}
|
|
|
1149 |
}
|
|
|
1150 |
|
|
|
1151 |
System::Void PackageForm::PackageForm_Closing(System::Object^ sender, CancelEventArgs^ e) {
|
|
|
1152 |
if ( m_pPackage->IsChanged() )
|
|
|
1153 |
{
|
|
|
1154 |
String ^name = m_pTabPage->Text;
|
|
|
1155 |
if ( name[name->Length - 1] == '*' )
|
|
|
1156 |
name = name->Remove(name->Length - 1);
|
|
|
1157 |
System::Windows::Forms::DialogResult result = MessageBox::Show("Would you like to save changes to the package?\n\n" + name, "Save Package", MessageBoxButtons::YesNoCancel, MessageBoxIcon::Question);
|
|
|
1158 |
|
|
|
1159 |
if ( result == System::Windows::Forms::DialogResult::Cancel )
|
|
|
1160 |
{
|
|
|
1161 |
e->Cancel = true;
|
|
|
1162 |
return;
|
|
|
1163 |
}
|
|
|
1164 |
else if ( result == System::Windows::Forms::DialogResult::Yes )
|
|
|
1165 |
{
|
|
|
1166 |
if ( !this->CheckSave() )
|
|
|
1167 |
{
|
|
|
1168 |
e->Cancel = true;
|
|
|
1169 |
return;
|
|
|
1170 |
}
|
|
|
1171 |
|
|
|
1172 |
if ( m_pPackage->GetFilename().Empty() )
|
|
|
1173 |
{
|
|
|
1174 |
SaveFileDialog ^ofd = gcnew SaveFileDialog();
|
|
|
1175 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
1176 |
ofd->Filter = "Ship Files (*.xsp)|*.xsp";
|
|
|
1177 |
else
|
|
|
1178 |
ofd->Filter = "Package Files (*.spk)|*.spk";
|
|
|
1179 |
ofd->FilterIndex = 1;
|
|
|
1180 |
ofd->RestoreDirectory = true;
|
|
|
1181 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1182 |
m_pPackage->SetFilename(CyStringFromSystemString(ofd->FileName));
|
|
|
1183 |
else
|
|
|
1184 |
{
|
|
|
1185 |
e->Cancel = true;
|
|
|
1186 |
return;
|
|
|
1187 |
}
|
|
|
1188 |
}
|
|
|
1189 |
|
|
|
1190 |
if ( !m_pPackage->WriteFile(m_pPackage->GetFilename()) )
|
|
|
1191 |
{
|
|
|
1192 |
e->Cancel = true;
|
|
|
1193 |
MessageBox::Show("Unable to save package\n" + SystemStringFromCyString(m_pPackage->GetFilename()), "Save Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
1194 |
return;
|
|
|
1195 |
}
|
|
|
1196 |
}
|
|
|
1197 |
}
|
|
|
1198 |
|
|
|
1199 |
delete m_pPackage;
|
|
|
1200 |
m_pPackage = NULL;
|
|
|
1201 |
}
|
|
|
1202 |
|
|
|
1203 |
void PackageForm::UpdateMirrors()
|
|
|
1204 |
{
|
|
|
1205 |
this->ListMirrors->Items->Clear();
|
|
|
1206 |
for ( int i = 0; i < m_pPackage->GetMaxWebMirrors(); i++ )
|
|
|
1207 |
{
|
|
|
1208 |
ListViewItem ^item = gcnew ListViewItem(SystemStringFromCyString(m_pPackage->GetWebMirror(i)));
|
|
|
1209 |
this->ListMirrors->Items->Add(item);
|
|
|
1210 |
item->ImageIndex = 1;
|
|
|
1211 |
}
|
|
|
1212 |
|
|
|
1213 |
this->ListMirrors->AutoResizeColumns(ColumnHeaderAutoResizeStyle::ColumnContent);
|
|
|
1214 |
if ( this->ListMirrors->Columns[0]->Width < 100 )
|
|
|
1215 |
this->ListMirrors->Columns[0]->Width = 100;
|
|
|
1216 |
}
|
|
|
1217 |
|
|
|
1218 |
void PackageForm::UpdatePackageNames()
|
|
|
1219 |
{
|
|
|
1220 |
this->ListNames->Items->Clear();
|
|
|
1221 |
for ( SNames *n = m_pPackage->GetNamesList()->First(); n; n = m_pPackage->GetNamesList()->Next() )
|
|
|
1222 |
{
|
|
|
1223 |
ListViewItem ^item = gcnew ListViewItem(Convert::ToString(n->iLanguage));
|
|
|
1224 |
item->SubItems->Add(SystemStringFromCyString(n->sName));
|
|
|
1225 |
item->ImageIndex = 0;
|
|
|
1226 |
this->ListNames->Items->Add(item);
|
|
|
1227 |
}
|
|
|
1228 |
this->ListNames->AutoResizeColumns(ColumnHeaderAutoResizeStyle::ColumnContent);
|
|
|
1229 |
if ( this->ListNames->Columns[0]->Width < 100 )
|
|
|
1230 |
this->ListNames->Columns[0]->Width = 100;
|
|
|
1231 |
if ( this->ListNames->Columns[1]->Width < 100 )
|
|
|
1232 |
this->ListNames->Columns[1]->Width = 100;
|
|
|
1233 |
}
|
|
|
1234 |
|
|
|
1235 |
void PackageForm::AddDisplayPic()
|
|
|
1236 |
{
|
|
|
1237 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
1238 |
ofd->Filter = "Display Images|*.gif;*.png;*.jpg";
|
|
|
1239 |
ofd->FilterIndex = 1;
|
|
|
1240 |
ofd->RestoreDirectory = true;
|
|
|
1241 |
ofd->Multiselect = true;
|
|
|
1242 |
ofd->Title = "Select the Display image to add";
|
|
|
1243 |
|
|
|
1244 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1245 |
{
|
|
|
1246 |
array<System::String ^> ^fileArray = ofd->FileNames;
|
|
|
1247 |
for ( int i = 0; i < fileArray->Length; i++ )
|
|
|
1248 |
{
|
|
|
1249 |
CyString file = CyStringFromSystemString(fileArray[i]);
|
|
|
1250 |
m_pDisplayFile = m_pPackage->AddFile(file, "", FILETYPE_ADVERT);
|
|
|
1251 |
}
|
|
|
1252 |
|
|
|
1253 |
this->UpdateDisplayPic();
|
|
|
1254 |
this->UpdateFileList();
|
|
|
1255 |
}
|
|
|
1256 |
}
|
|
|
1257 |
|
|
|
1258 |
void PackageForm::AddDisplayIcon()
|
|
|
1259 |
{
|
|
|
1260 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
1261 |
ofd->Filter = "Icon Files|*.ico;*.png;*.bmp";
|
|
|
1262 |
ofd->FilterIndex = 1;
|
|
|
1263 |
ofd->RestoreDirectory = true;
|
|
|
1264 |
ofd->Multiselect = false;
|
|
|
1265 |
ofd->Title = "Select the Icon file to add";
|
|
|
1266 |
|
|
|
1267 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1268 |
{
|
|
|
1269 |
CyString file = CyStringFromSystemString(ofd->FileName);
|
|
|
1270 |
C_File *icon = new C_File(file);
|
|
|
1271 |
if ( icon->ReadFromFile() )
|
|
|
1272 |
m_pPackage->SetIcon(icon, CFileIO(file).GetFileExtension());
|
|
|
1273 |
|
|
|
1274 |
this->UpdateDisplayIcon();
|
|
|
1275 |
this->UpdateChanged();
|
|
|
1276 |
}
|
|
|
1277 |
}
|
|
|
1278 |
|
|
|
1279 |
void PackageForm::SaveText()
|
|
|
1280 |
{
|
|
|
1281 |
if ( this->TextText->Text->Length )
|
|
|
1282 |
{
|
|
|
1283 |
if ( this->ListLang->SelectedIndex >= 0 )
|
|
|
1284 |
{
|
|
|
1285 |
int lang = CyStringFromSystemString(this->ListLang->Text).ToInt();
|
|
|
1286 |
if ( this->RadioInstallAfter->Checked )
|
|
|
1287 |
m_pPackage->AddInstallAfterText(lang, CyStringFromSystemString(this->TextText->Text));
|
|
|
1288 |
else if ( this->RadioInstallBefore->Checked )
|
|
|
1289 |
m_pPackage->AddInstallBeforeText(lang, CyStringFromSystemString(this->TextText->Text));
|
|
|
1290 |
else if ( this->RadioUninstallBefore->Checked )
|
|
|
1291 |
m_pPackage->AddUninstallBeforeText(lang, CyStringFromSystemString(this->TextText->Text));
|
|
|
1292 |
else if ( this->RadioUninstallAfter->Checked )
|
|
|
1293 |
m_pPackage->AddUninstallAfterText(lang, CyStringFromSystemString(this->TextText->Text));
|
|
|
1294 |
this->UpdateChanged();
|
|
|
1295 |
}
|
|
|
1296 |
}
|
|
|
1297 |
}
|
|
|
1298 |
|
|
|
1299 |
void PackageForm::LoadShipData()
|
|
|
1300 |
{
|
|
|
1301 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
1302 |
ofd->Filter = "All (*.cat, tships)|*.cat;tships.txt;tships.pck|TShips Files (tships.txt/pck)|tships.txt;tships.pck|Mod Files (*.cat)|*.cat";
|
|
|
1303 |
ofd->FilterIndex = 1;
|
|
|
1304 |
ofd->RestoreDirectory = true;
|
|
|
1305 |
ofd->Multiselect = false;
|
|
|
1306 |
ofd->Title = "Select the TShips/Mod file to load ship data from";
|
|
|
1307 |
|
|
|
1308 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1309 |
{
|
|
|
1310 |
// if its a cat file, lets load the text
|
|
|
1311 |
Hashtable ^catText = gcnew Hashtable();
|
|
|
1312 |
|
|
|
1313 |
if ( String::Compare(IO::FileInfo(ofd->FileName).Extension, ".cat") == 0 )
|
|
|
1314 |
{
|
|
|
1315 |
CyStringList readText;
|
|
|
1316 |
if ( m_pP->ReadTextPage(CyStringFromSystemString(ofd->FileName), &readText, false, 17) )
|
|
|
1317 |
{
|
|
|
1318 |
for ( SStringList *str = readText.Head(); str; str = str->next )
|
|
|
1319 |
{
|
|
|
1320 |
String ^key = SystemStringFromCyString(str->str);
|
|
|
1321 |
if ( catText->ContainsKey(key) )
|
|
|
1322 |
catText[key] = SystemStringFromCyString(str->data);
|
|
|
1323 |
else
|
|
|
1324 |
catText->Add(key, SystemStringFromCyString(str->data));
|
|
|
1325 |
}
|
|
|
1326 |
}
|
|
|
1327 |
}
|
|
|
1328 |
|
|
|
1329 |
CyStringList list;
|
|
|
1330 |
if ( m_pP->LoadShipData(CyStringFromSystemString(ofd->FileName), &list) )
|
|
|
1331 |
{
|
|
|
1332 |
LoadShip ^ls = gcnew LoadShip();
|
|
|
1333 |
for ( SStringList *str = list.Head(); str; str = str->next )
|
|
|
1334 |
{
|
|
|
1335 |
int tId = str->data.GetToken(";", 7, 7).ToInt();
|
|
|
1336 |
String ^name;
|
|
|
1337 |
if ( catText->ContainsKey(Convert::ToString(tId)) )
|
|
|
1338 |
name = Convert::ToString(catText[Convert::ToString(tId)]);
|
|
|
1339 |
else
|
|
|
1340 |
name = ((Form1 ^)this->MdiParent)->FindText(-1, 17, tId);
|
|
|
1341 |
String ^text = ((Form1 ^)this->MdiParent)->FindText(-1, 1266, str->data.GetToken(";", 46, 46).ToInt()) + " " + name;
|
|
|
1342 |
int variation = str->data.GetToken(";", 51, 51).ToInt();
|
|
|
1343 |
if ( variation )
|
|
|
1344 |
text = text + " " + ((Form1 ^)this->MdiParent)->FindText(-1, 17, 10000 + variation);
|
|
|
1345 |
ls->AddShip(SystemStringFromCyString(str->str), text);
|
|
|
1346 |
}
|
|
|
1347 |
|
|
|
1348 |
if ( ls->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1349 |
{
|
|
|
1350 |
SStringList *str = list.FindString(CyStringFromSystemString(ls->GetData()));
|
|
|
1351 |
if ( str )
|
|
|
1352 |
{
|
14 |
cycrow |
1353 |
((CXspFile *)m_pPackage)->SetShipData(str->data.ToString());
|
|
|
1354 |
if ( ((CXspFile *)m_pPackage)->GetShipID().empty() )
|
1 |
cycrow |
1355 |
{
|
|
|
1356 |
CyString id = str->data.GetToken(";", -2);
|
|
|
1357 |
while ( id.Right(1) == ";" )
|
|
|
1358 |
id.Truncate((int)id.Length() - 1);
|
14 |
cycrow |
1359 |
((CXspFile *)m_pPackage)->SetShipID(id.ToString());
|
1 |
cycrow |
1360 |
this->TextShipID->Text = SystemStringFromCyString(id);
|
|
|
1361 |
}
|
|
|
1362 |
|
14 |
cycrow |
1363 |
((CXspFile *)m_pPackage)->SetShipData(str->data.ToString());
|
1 |
cycrow |
1364 |
this->TextShipData->Text = SystemStringFromCyString(str->data);
|
|
|
1365 |
this->NumTextID->Value = str->data.GetToken(";", 7, 7).ToInt();
|
|
|
1366 |
this->UpdateChanged();
|
|
|
1367 |
}
|
|
|
1368 |
}
|
|
|
1369 |
}
|
|
|
1370 |
else
|
|
|
1371 |
MessageBox::Show(this, "Unable to find any ship entries, invalid/missing TShips?", "Error Loading", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
1372 |
}
|
|
|
1373 |
}
|
|
|
1374 |
|
|
|
1375 |
void PackageForm::EditShipParts(bool edit)
|
|
|
1376 |
{
|
|
|
1377 |
CXspFile *xsp = (CXspFile *)m_pPackage;
|
|
|
1378 |
switch ( this->ComboShipPart->SelectedIndex )
|
|
|
1379 |
{
|
|
|
1380 |
case 0:
|
|
|
1381 |
{
|
|
|
1382 |
AddShipPart ^component = gcnew AddShipPart((Form1 ^)this->MdiParent);
|
|
|
1383 |
component->SetComponent(edit);
|
|
|
1384 |
|
|
|
1385 |
if ( edit )
|
|
|
1386 |
{
|
|
|
1387 |
component->SetSection(m_pSelectedItem->Text);
|
|
|
1388 |
component->SetSection2(m_pSelectedItem->SubItems[1]->Text);
|
|
|
1389 |
component->SetData(m_pSelectedItem->SubItems[2]->Text);
|
|
|
1390 |
}
|
|
|
1391 |
|
|
|
1392 |
if ( component->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1393 |
{
|
|
|
1394 |
if ( edit )
|
|
|
1395 |
xsp->RemoveComponent(CyStringFromSystemString(m_pSelectedItem->Text), CyStringFromSystemString(m_pSelectedItem->SubItems[1]->Text), CyStringFromSystemString(m_pSelectedItem->SubItems[2]->Text));
|
|
|
1396 |
xsp->AddComponent(CyStringFromSystemString(component->GetSection()), CyStringFromSystemString(component->GetSection2()), CyStringFromSystemString(component->GetData()));
|
|
|
1397 |
if ( !edit )
|
|
|
1398 |
this->UpdateShipPartList();
|
|
|
1399 |
else
|
|
|
1400 |
{
|
|
|
1401 |
m_pSelectedItem->Text = component->GetSection();
|
|
|
1402 |
m_pSelectedItem->SubItems[1]->Text = component->GetSection2();
|
|
|
1403 |
m_pSelectedItem->SubItems[2]->Text = component->GetData();
|
|
|
1404 |
}
|
|
|
1405 |
}
|
|
|
1406 |
}
|
|
|
1407 |
break;
|
|
|
1408 |
case 1:
|
|
|
1409 |
{
|
|
|
1410 |
AddShipPart ^dummy = gcnew AddShipPart((Form1 ^)this->MdiParent);
|
|
|
1411 |
dummy->SetDummy(edit);
|
|
|
1412 |
|
|
|
1413 |
if ( edit )
|
|
|
1414 |
{
|
|
|
1415 |
dummy->SetSection(m_pSelectedItem->Text);
|
|
|
1416 |
dummy->SetData(m_pSelectedItem->SubItems[1]->Text);
|
|
|
1417 |
}
|
|
|
1418 |
|
|
|
1419 |
if ( dummy->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1420 |
{
|
|
|
1421 |
if ( edit )
|
|
|
1422 |
xsp->RemoveDummy(CyStringFromSystemString(m_pSelectedItem->Text), CyStringFromSystemString(m_pSelectedItem->SubItems[1]->Text));
|
|
|
1423 |
xsp->AddDummy(CyStringFromSystemString(dummy->GetSection()), CyStringFromSystemString(dummy->GetData()));
|
|
|
1424 |
if ( !edit )
|
|
|
1425 |
this->UpdateShipPartList();
|
|
|
1426 |
else
|
|
|
1427 |
{
|
|
|
1428 |
m_pSelectedItem->Text = dummy->GetSection();
|
|
|
1429 |
m_pSelectedItem->SubItems[1]->Text = dummy->GetData();
|
|
|
1430 |
}
|
|
|
1431 |
}
|
|
|
1432 |
}
|
|
|
1433 |
break;
|
|
|
1434 |
|
|
|
1435 |
case 2:
|
|
|
1436 |
{
|
|
|
1437 |
AddCockpit ^cockpit = gcnew AddCockpit();
|
|
|
1438 |
if ( edit )
|
|
|
1439 |
cockpit->SetEdit(m_pSelectedItem->Text, SystemStringFromCyString(CyStringFromSystemString(m_pSelectedItem->SubItems[2]->Text).GetToken(";", 8, 8)), CyStringFromSystemString(m_pSelectedItem->SubItems[2]->Text).GetToken(";", 9, 9).ToInt());
|
|
|
1440 |
if ( cockpit->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1441 |
{
|
|
|
1442 |
if ( !edit )
|
|
|
1443 |
{
|
|
|
1444 |
xsp->NewCockpit(CyStringFromSystemString(cockpit->GetID()), CyStringFromSystemString(cockpit->GetScene()), cockpit->GetMask());
|
|
|
1445 |
this->UpdateShipPartList();
|
|
|
1446 |
}
|
|
|
1447 |
else
|
|
|
1448 |
{
|
|
|
1449 |
xsp->EditCockpit(CyStringFromSystemString(cockpit->GetID()), CyStringFromSystemString(cockpit->GetScene()), cockpit->GetMask());
|
|
|
1450 |
m_pSelectedItem->SubItems[2]->Text = SystemStringFromCyString(xsp->GetCockpitData(CyStringFromSystemString(cockpit->GetID())));
|
|
|
1451 |
}
|
|
|
1452 |
}
|
|
|
1453 |
}
|
|
|
1454 |
break;
|
|
|
1455 |
|
|
|
1456 |
case 3:
|
|
|
1457 |
{
|
|
|
1458 |
if ( edit )
|
|
|
1459 |
{
|
|
|
1460 |
InputBox ^input2 = gcnew InputBox("Enter the filename for cut id: " + SystemStringFromCyString(CyStringFromSystemString(m_pSelectedItem->Text).GetToken(";", 1, 1)), SystemStringFromCyString(CyStringFromSystemString(m_pSelectedItem->Text).GetToken(";", 2, 2)));
|
|
|
1461 |
if ( input2->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1462 |
{
|
|
|
1463 |
xsp->RemoveCutData(CyStringFromSystemString(m_pSelectedItem->Text));
|
|
|
1464 |
xsp->AddCutData(CyStringFromSystemString(SystemStringFromCyString(CyStringFromSystemString(m_pSelectedItem->Text).GetToken(";", 1, 1)) + "; " + input2->GetInput()));
|
|
|
1465 |
this->UpdateShipPartList();
|
|
|
1466 |
}
|
|
|
1467 |
}
|
|
|
1468 |
else
|
|
|
1469 |
{
|
|
|
1470 |
InputBox ^input = gcnew InputBox("Enter the cut id to add");
|
|
|
1471 |
if ( input->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1472 |
{
|
|
|
1473 |
InputBox ^input2 = gcnew InputBox("Enter the filename for cut id: " + input->GetInput());
|
|
|
1474 |
if ( input2->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1475 |
{
|
|
|
1476 |
xsp->AddCutData(CyStringFromSystemString(input->GetInput() + "; " + input2->GetInput()));
|
|
|
1477 |
this->UpdateShipPartList();
|
|
|
1478 |
}
|
|
|
1479 |
}
|
|
|
1480 |
}
|
|
|
1481 |
}
|
|
|
1482 |
break;
|
|
|
1483 |
|
|
|
1484 |
case 4:
|
|
|
1485 |
{
|
|
|
1486 |
AddShipPart ^dummy = gcnew AddShipPart((Form1 ^)this->MdiParent);
|
|
|
1487 |
dummy->SetBodies(edit);
|
|
|
1488 |
|
|
|
1489 |
if ( edit )
|
|
|
1490 |
{
|
|
|
1491 |
dummy->SetSection(m_pSelectedItem->Text);
|
|
|
1492 |
dummy->SetData(m_pSelectedItem->SubItems[1]->Text);
|
|
|
1493 |
}
|
|
|
1494 |
|
|
|
1495 |
if ( dummy->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1496 |
{
|
|
|
1497 |
if ( edit )
|
|
|
1498 |
xsp->RemoveBodies(CyStringFromSystemString(m_pSelectedItem->Text + ";" + m_pSelectedItem->SubItems[1]->Text));
|
|
|
1499 |
xsp->AddBodies(CyStringFromSystemString(dummy->GetSection() + ";" + dummy->GetData()));
|
|
|
1500 |
if ( !edit )
|
|
|
1501 |
this->UpdateShipPartList();
|
|
|
1502 |
else
|
|
|
1503 |
{
|
|
|
1504 |
m_pSelectedItem->Text = dummy->GetSection();
|
|
|
1505 |
m_pSelectedItem->SubItems[1]->Text = dummy->GetData();
|
|
|
1506 |
}
|
|
|
1507 |
}
|
|
|
1508 |
}
|
|
|
1509 |
break;
|
|
|
1510 |
|
|
|
1511 |
case 5:
|
|
|
1512 |
{
|
|
|
1513 |
InputBox ^input = gcnew InputBox("Enter the animation data to add", (!edit) ? "" : m_pSelectedItem->Text);
|
|
|
1514 |
input->Large();
|
|
|
1515 |
if ( input->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1516 |
{
|
|
|
1517 |
if ( edit )
|
|
|
1518 |
xsp->RemoveAnimation(CyStringFromSystemString(m_pSelectedItem->Text));
|
|
|
1519 |
xsp->AddAnimation(CyStringFromSystemString(input->GetInput()));
|
|
|
1520 |
this->UpdateShipPartList();
|
|
|
1521 |
}
|
|
|
1522 |
}
|
|
|
1523 |
break;
|
|
|
1524 |
}
|
|
|
1525 |
}
|
|
|
1526 |
|
|
|
1527 |
void PackageForm::DropGetDirectories(String ^dir, CyStringList *list, bool packages)
|
|
|
1528 |
{
|
|
|
1529 |
cli::array<String ^> ^dirList = IO::Directory::GetFileSystemEntries(dir);
|
|
|
1530 |
for ( int j = 0; j < dirList->Length; j++ )
|
|
|
1531 |
{
|
|
|
1532 |
if ( IO::DirectoryInfo(dirList[j]).Exists )
|
|
|
1533 |
this->DropGetDirectories(dirList[j], list, packages);
|
|
|
1534 |
else
|
|
|
1535 |
{
|
|
|
1536 |
if ( packages )
|
|
|
1537 |
list->PushBack(CyStringFromSystemString(dirList[j]), "-1");
|
|
|
1538 |
else
|
18 |
cycrow |
1539 |
list->PushBack(CyStringFromSystemString(dirList[j]), CyString::Number(SPK::GetAutomaticFiletype(CyStringFromSystemString(dirList[j]), NULL,false)));
|
1 |
cycrow |
1540 |
}
|
|
|
1541 |
}
|
|
|
1542 |
}
|
|
|
1543 |
|
|
|
1544 |
void PackageForm::RemoveSelectedFiles()
|
|
|
1545 |
{
|
|
|
1546 |
CLinkList<C_File> removeFiles;
|
|
|
1547 |
for ( int i = 0; i < ListFiles->SelectedItems->Count; i++ )
|
|
|
1548 |
{
|
|
|
1549 |
int id = CyStringFromSystemString(cli::safe_cast<System::String ^>(this->ListFiles->SelectedItems[i]->Tag)).ToInt();
|
|
|
1550 |
C_File *file = m_pPackage->GetFileList()->Get(id);
|
|
|
1551 |
if ( m_pDisplayFile == file )
|
|
|
1552 |
m_pDisplayFile = NULL;
|
|
|
1553 |
removeFiles.push_back(file);
|
|
|
1554 |
}
|
|
|
1555 |
|
|
|
1556 |
if ( removeFiles.size() )
|
|
|
1557 |
{
|
|
|
1558 |
for ( C_File *f = removeFiles.First(); f; f = removeFiles.Next() )
|
|
|
1559 |
m_pPackage->RemoveFile(f);
|
|
|
1560 |
m_pPackage->UpdateSigned(false);
|
|
|
1561 |
this->UpdateFileList();
|
|
|
1562 |
this->UpdateDisplayPic();
|
|
|
1563 |
this->UpdateChanged();
|
|
|
1564 |
}
|
|
|
1565 |
|
|
|
1566 |
if ( !ListFiles->SelectedItems->Count )
|
|
|
1567 |
this->ButRemoveFile->Enabled = false;
|
|
|
1568 |
}
|
|
|
1569 |
|
|
|
1570 |
String ^PackageForm::ExtractImport(String ^file, String ^type)
|
|
|
1571 |
{
|
|
|
1572 |
if ( String::Compare(IO::FileInfo(file).Extension, ".xml") == 0 )
|
|
|
1573 |
return file;
|
|
|
1574 |
|
|
|
1575 |
if ( String::Compare(IO::FileInfo(file).Extension, ".pck") == 0 )
|
|
|
1576 |
{
|
|
|
1577 |
C_File F(CyStringFromSystemString(file));
|
|
|
1578 |
F.UnPCKFile();
|
|
|
1579 |
if ( F.WriteToFile("tmp") )
|
|
|
1580 |
return "tmp";
|
|
|
1581 |
}
|
|
|
1582 |
else if ( String::Compare(IO::FileInfo(file).Extension, ".cat") == 0 )
|
|
|
1583 |
{
|
|
|
1584 |
CCatFile cat;
|
|
|
1585 |
if ( cat.Open(CyStringFromSystemString(file), "", CATREAD_CATDECRYPT, false) == CATERR_NONE )
|
|
|
1586 |
{
|
|
|
1587 |
if ( cat.ExtractFile(CyStringFromSystemString("types\\" + type + ".pck"), "tmp") )
|
|
|
1588 |
return "tmp";
|
|
|
1589 |
}
|
|
|
1590 |
}
|
|
|
1591 |
|
|
|
1592 |
return "";
|
|
|
1593 |
}
|
|
|
1594 |
|
|
|
1595 |
int PackageForm::GetHighestGame()
|
|
|
1596 |
{
|
|
|
1597 |
return ((Form1 ^)this->MdiParent)->GetHighestGame();
|
|
|
1598 |
}
|
|
|
1599 |
|
|
|
1600 |
|
|
|
1601 |
void PackageForm::ImportData(String ^file, int type)
|
|
|
1602 |
{
|
|
|
1603 |
CFileIO F(CyStringFromSystemString(file));
|
|
|
1604 |
if ( !F.Exists() )
|
|
|
1605 |
return;
|
|
|
1606 |
|
|
|
1607 |
CyStringList *lines = F.ReadLinesStr();
|
|
|
1608 |
if ( !lines )
|
|
|
1609 |
return;
|
|
|
1610 |
|
|
|
1611 |
LoadShip ^load = gcnew LoadShip();
|
|
|
1612 |
|
|
|
1613 |
int entryPos = 1;
|
|
|
1614 |
int dataPos = 1;
|
|
|
1615 |
int dataPos2 = 0;
|
|
|
1616 |
bool sections = false;
|
|
|
1617 |
CyString section;
|
|
|
1618 |
switch ( type )
|
|
|
1619 |
{
|
|
|
1620 |
case 2:
|
|
|
1621 |
entryPos = 2;
|
|
|
1622 |
dataPos = 19;
|
|
|
1623 |
load->Cockpits();
|
|
|
1624 |
break;
|
|
|
1625 |
case 3:
|
|
|
1626 |
dataPos2 = 2;
|
|
|
1627 |
load->CutData();
|
|
|
1628 |
break;
|
|
|
1629 |
case 4:
|
|
|
1630 |
sections = true;
|
|
|
1631 |
entryPos = 2;
|
|
|
1632 |
load->Bodies();
|
|
|
1633 |
break;
|
|
|
1634 |
case 1:
|
|
|
1635 |
sections = true;
|
|
|
1636 |
entryPos = 2;
|
|
|
1637 |
dataPos = -1;
|
|
|
1638 |
load->Dummies();
|
|
|
1639 |
break;
|
|
|
1640 |
case 0:
|
|
|
1641 |
sections = true;
|
|
|
1642 |
entryPos = 2;
|
|
|
1643 |
dataPos = -1;
|
|
|
1644 |
load->Components();
|
|
|
1645 |
break;
|
|
|
1646 |
}
|
|
|
1647 |
|
|
|
1648 |
int entries2 = 0;
|
|
|
1649 |
int entries = -1;
|
|
|
1650 |
CyStringList list;
|
|
|
1651 |
CyString data;
|
|
|
1652 |
int e = 0;
|
|
|
1653 |
for ( SStringList *str = lines->Head(); str; str = str->next )
|
|
|
1654 |
{
|
|
|
1655 |
str->str.RemoveChar(9);
|
|
|
1656 |
str->str.RemoveChar('\r');
|
|
|
1657 |
str->str.RemoveFirstSpace();
|
|
|
1658 |
if ( str->str.Empty() )
|
|
|
1659 |
continue;
|
|
|
1660 |
if ( str->str[0] == '/' )
|
|
|
1661 |
continue;
|
|
|
1662 |
|
|
|
1663 |
if ( entries == -1 || (entries <= 0 && sections) )
|
|
|
1664 |
{
|
|
|
1665 |
entries = str->str.GetToken(";", entryPos, entryPos).ToInt();
|
|
|
1666 |
if ( sections )
|
|
|
1667 |
{
|
|
|
1668 |
section = str->str.GetToken(";", 1, 1);
|
|
|
1669 |
load->AddGroup(SystemStringFromCyString(section));
|
|
|
1670 |
}
|
|
|
1671 |
}
|
|
|
1672 |
else
|
|
|
1673 |
{
|
|
|
1674 |
if ( type == 4 )
|
|
|
1675 |
{
|
|
|
1676 |
int max;
|
|
|
1677 |
CyString *strs = str->str.SplitToken(";", &max);
|
|
|
1678 |
if ( max && strs )
|
|
|
1679 |
{
|
|
|
1680 |
for ( int i = 0; i < max; i++ )
|
|
|
1681 |
{
|
|
|
1682 |
strs[i].RemoveFirstSpace();
|
|
|
1683 |
if ( strs[i].Empty() ) continue;
|
|
|
1684 |
CyString id = strs[i].GetToken(";", dataPos, dataPos);
|
|
|
1685 |
load->AddShip(SystemStringFromCyString(id), "");
|
|
|
1686 |
list.PushBack(id, CyString::Number(e) + " " + section + ";" + strs[i]);
|
|
|
1687 |
++e;
|
|
|
1688 |
--entries;
|
|
|
1689 |
}
|
|
|
1690 |
}
|
|
|
1691 |
|
|
|
1692 |
CLEANSPLIT(strs, max)
|
|
|
1693 |
}
|
|
|
1694 |
else if ( type == 0 )
|
|
|
1695 |
{
|
|
|
1696 |
if ( entries2 )
|
|
|
1697 |
{
|
|
|
1698 |
load->AddShip(SystemStringFromCyString(data), SystemStringFromCyString(str->str));
|
|
|
1699 |
list.PushBack(data, section + ";" + data + ";" + str->str);
|
|
|
1700 |
--entries2;
|
|
|
1701 |
}
|
|
|
1702 |
else
|
|
|
1703 |
{
|
|
|
1704 |
data = str->str.GetToken(";", 1, 1);
|
|
|
1705 |
entries2 = str->str.GetToken(";", 2, 2).ToInt();
|
|
|
1706 |
++e;
|
|
|
1707 |
--entries;
|
|
|
1708 |
}
|
|
|
1709 |
}
|
|
|
1710 |
else
|
|
|
1711 |
{
|
|
|
1712 |
CyString id;
|
|
|
1713 |
if ( dataPos == -1 )
|
|
|
1714 |
id = str->str;
|
|
|
1715 |
else
|
|
|
1716 |
id = str->str.GetToken(";", dataPos, dataPos);
|
|
|
1717 |
|
|
|
1718 |
if ( dataPos2 )
|
|
|
1719 |
load->AddShip(SystemStringFromCyString(id), SystemStringFromCyString(str->str.GetToken(";", dataPos2, dataPos2)));
|
|
|
1720 |
else
|
|
|
1721 |
load->AddShip(SystemStringFromCyString(id), "");
|
|
|
1722 |
if ( sections )
|
|
|
1723 |
list.PushBack(id, CyString::Number(e) + " " + section + ";" + str->str);
|
|
|
1724 |
else
|
|
|
1725 |
list.PushBack(id, CyString::Number(e) + " " + str->str);
|
|
|
1726 |
++e;
|
|
|
1727 |
--entries;
|
|
|
1728 |
}
|
|
|
1729 |
}
|
|
|
1730 |
}
|
|
|
1731 |
|
|
|
1732 |
if ( load->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1733 |
{
|
|
|
1734 |
for ( SStringList *str = load->GetDataList()->Head(); str; str = str->next )
|
|
|
1735 |
{
|
|
|
1736 |
SStringList *s = list.FindString(str->str);
|
|
|
1737 |
if ( s )
|
|
|
1738 |
{
|
|
|
1739 |
switch ( type )
|
|
|
1740 |
{
|
|
|
1741 |
case 0:
|
|
|
1742 |
((CXspFile *)m_pPackage)->AddComponent(s->data.GetToken(";", 1, 1), s->data.GetToken(";", 2, 2), s->data.GetToken(";", 3));
|
|
|
1743 |
break;
|
|
|
1744 |
case 2:
|
|
|
1745 |
((CXspFile *)m_pPackage)->AddCockpit(s->data.GetToken(" ", 2), 0, -1, s->data.GetToken(" ", 1, 1).ToInt());
|
|
|
1746 |
break;
|
|
|
1747 |
case 3:
|
|
|
1748 |
((CXspFile *)m_pPackage)->AddCutData(s->data.GetToken(" ", 2));
|
|
|
1749 |
break;
|
|
|
1750 |
case 4:
|
|
|
1751 |
((CXspFile *)m_pPackage)->AddBodies(s->data.GetToken(" ", 2));
|
|
|
1752 |
break;
|
|
|
1753 |
case 1:
|
|
|
1754 |
((CXspFile *)m_pPackage)->AddDummy(s->data.GetToken(" ", 2).GetToken(";", 1, 1), s->data.GetToken(" ", 2).GetToken(";", 2));
|
|
|
1755 |
break;
|
|
|
1756 |
}
|
|
|
1757 |
}
|
|
|
1758 |
}
|
|
|
1759 |
|
|
|
1760 |
this->UpdateShipPartList();
|
|
|
1761 |
this->UpdateChanged();
|
|
|
1762 |
}
|
|
|
1763 |
|
|
|
1764 |
delete lines;
|
|
|
1765 |
}
|
|
|
1766 |
|
|
|
1767 |
void PackageForm::ImportAnimations(String ^file)
|
|
|
1768 |
{
|
|
|
1769 |
CFileIO F(CyStringFromSystemString(file));
|
|
|
1770 |
if ( !F.Exists() )
|
|
|
1771 |
return;
|
|
|
1772 |
|
|
|
1773 |
CyStringList *lines = F.ReadLinesStr();
|
|
|
1774 |
if ( !lines )
|
|
|
1775 |
return;
|
|
|
1776 |
|
|
|
1777 |
|
|
|
1778 |
CyStringList lOut;
|
|
|
1779 |
if ( CXspFile::ReadAnimations(lines, &lOut, 0) )
|
|
|
1780 |
{
|
|
|
1781 |
LoadShip ^load = gcnew LoadShip();
|
|
|
1782 |
load->Animations();
|
|
|
1783 |
for ( SStringList *str = lOut.Head(); str; str = str->next )
|
|
|
1784 |
{
|
|
|
1785 |
load->AddShip(SystemStringFromCyString(str->str), "");
|
|
|
1786 |
}
|
|
|
1787 |
|
|
|
1788 |
if ( load->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1789 |
{
|
|
|
1790 |
((CXspFile *)m_pPackage)->AddAnimation(load->GetDataList());
|
|
|
1791 |
this->UpdateShipPartList();
|
|
|
1792 |
this->UpdateChanged();
|
|
|
1793 |
}
|
|
|
1794 |
}
|
|
|
1795 |
|
|
|
1796 |
delete lines;
|
|
|
1797 |
}
|
|
|
1798 |
|
|
|
1799 |
void PackageForm::EditDepend()
|
|
|
1800 |
{
|
|
|
1801 |
AddDepend ^depend = gcnew AddDepend();
|
|
|
1802 |
depend->SetEdit(m_pSelectedItem->Text, m_pSelectedItem->SubItems[1]->Text, m_pSelectedItem->SubItems[2]->Text);
|
|
|
1803 |
|
|
|
1804 |
bool builtin = false;
|
|
|
1805 |
if ( String::Compare("<package>", m_pSelectedItem->Text) == 0 && String::Compare("<author>", m_pSelectedItem->SubItems[1]->Text) == 0 )
|
|
|
1806 |
{
|
|
|
1807 |
builtin = true;
|
|
|
1808 |
depend->BuiltIn();
|
|
|
1809 |
}
|
|
|
1810 |
|
|
|
1811 |
if ( depend->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1812 |
{
|
|
|
1813 |
if ( builtin )
|
|
|
1814 |
{
|
|
|
1815 |
SNeededLibrary *ns = m_pPackage->FindPackageNeeded("<package>", "<author>");
|
|
|
1816 |
if ( ns )
|
|
|
1817 |
ns->sMinVersion = CyStringFromSystemString(depend->GetVersion());
|
|
|
1818 |
}
|
|
|
1819 |
else
|
|
|
1820 |
{
|
|
|
1821 |
m_pPackage->RemovePackageNeeded(CyStringFromSystemString(m_pSelectedItem->Text), CyStringFromSystemString(m_pSelectedItem->SubItems[1]->Text));
|
|
|
1822 |
m_pPackage->AddNeededLibrary(CyStringFromSystemString(depend->GetName()), CyStringFromSystemString(depend->GetAuthor()), CyStringFromSystemString(depend->GetVersion()));
|
|
|
1823 |
}
|
|
|
1824 |
this->UpdateDependacies();
|
|
|
1825 |
this->UpdateChanged();
|
|
|
1826 |
}
|
|
|
1827 |
}
|
|
|
1828 |
}
|