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"
|
237 |
cycrow |
8 |
#include "AddGlobal.h"
|
1 |
cycrow |
9 |
|
46 |
cycrow |
10 |
#include <Package/InstallText.h>
|
|
|
11 |
|
1 |
cycrow |
12 |
namespace Creator {
|
131 |
cycrow |
13 |
void PackageForm::_init()
|
127 |
cycrow |
14 |
{
|
|
|
15 |
this->LabelShipWarning->Visible = false;
|
|
|
16 |
this->TextExactVersion->Visible = false;
|
|
|
17 |
this->DoToolTips();
|
|
|
18 |
|
|
|
19 |
this->ListDep->LargeImageList = this->imageList1;
|
|
|
20 |
this->ListDep->SmallImageList = this->imageList1;
|
237 |
cycrow |
21 |
this->listGlobals->LargeImageList = this->imageList1;
|
|
|
22 |
this->listGlobals->SmallImageList = this->imageList1;
|
127 |
cycrow |
23 |
|
|
|
24 |
m_iFormType = FORMTYPE_SINGLE;
|
|
|
25 |
m_pDisplayFile = NULL;
|
|
|
26 |
|
|
|
27 |
this->NumTextID->Visible = false;
|
|
|
28 |
|
|
|
29 |
m_iSelectedGame = -1;
|
|
|
30 |
|
|
|
31 |
this->Closing += gcnew CancelEventHandler(this, &PackageForm::PackageForm_Closing);
|
|
|
32 |
|
|
|
33 |
_pPackages = new CPackages();
|
264 |
cycrow |
34 |
_pPackages->startup(L".", _WS(IO::Path::GetTempPath()), _WS(Environment::GetFolderPath(Environment::SpecialFolder::Personal)));
|
127 |
cycrow |
35 |
m_pPackage = NULL;
|
214 |
cycrow |
36 |
m_pTypeList = new Utils::WStringList;
|
127 |
cycrow |
37 |
|
|
|
38 |
this->ComboShipPart->SelectedIndex = 0;
|
|
|
39 |
|
|
|
40 |
m_bLoading = false;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
PackageForm::~PackageForm()
|
|
|
44 |
{
|
|
|
45 |
if (components)
|
|
|
46 |
delete components;
|
|
|
47 |
|
|
|
48 |
delete m_pTypeList;
|
|
|
49 |
if (m_pPackage)
|
|
|
50 |
delete m_pPackage;
|
|
|
51 |
if (_pPackages)
|
|
|
52 |
delete _pPackages;
|
|
|
53 |
}
|
|
|
54 |
|
131 |
cycrow |
55 |
void PackageForm::SetImageLists(ImageList ^smallList, ImageList ^largeList, ImageList ^gameList, ImageList ^fileList)
|
|
|
56 |
{
|
|
|
57 |
BaseForm::SetImageLists(smallList, largeList, gameList);
|
127 |
cycrow |
58 |
|
131 |
cycrow |
59 |
this->ListGames->SmallImageList = this->imageListGames;
|
|
|
60 |
this->ListGames->LargeImageList = this->imageListGames;
|
|
|
61 |
this->ListNames->SmallImageList = this->imageListSmall;
|
|
|
62 |
this->ListMirrors->SmallImageList = this->imageListSmall;
|
|
|
63 |
this->ListWares->SmallImageList = this->imageListSmall;
|
|
|
64 |
this->ListWareText->SmallImageList = this->imageListSmall;
|
|
|
65 |
this->ListShipText->SmallImageList = this->imageListSmall;
|
|
|
66 |
this->ListShipPart->SmallImageList = this->imageListSmall;
|
|
|
67 |
|
|
|
68 |
this->ListNames->LargeImageList = this->imageListLarge;
|
|
|
69 |
this->ListMirrors->LargeImageList = this->imageListLarge;
|
|
|
70 |
this->ListWares->LargeImageList = this->imageListLarge;
|
|
|
71 |
this->ListWareText->LargeImageList = this->imageListLarge;
|
|
|
72 |
this->ListShipText->LargeImageList = this->imageListLarge;
|
|
|
73 |
this->ListShipPart->LargeImageList = this->imageListLarge;
|
|
|
74 |
|
|
|
75 |
this->ButGame->ImageList = this->imageListGames;
|
|
|
76 |
|
|
|
77 |
this->imageListFiles = fileList;
|
|
|
78 |
this->ListFiles->LargeImageList = this->imageListFiles;
|
|
|
79 |
this->ListFiles->SmallImageList = this->imageListFiles;
|
|
|
80 |
|
|
|
81 |
this->Setup();
|
|
|
82 |
}
|
|
|
83 |
|
1 |
cycrow |
84 |
bool PackageForm::LoadPackage(CBaseFile *base, System::String ^filename)
|
|
|
85 |
{
|
|
|
86 |
m_sFilename = filename;
|
|
|
87 |
|
|
|
88 |
if ( !base )
|
|
|
89 |
{
|
|
|
90 |
int error;
|
224 |
cycrow |
91 |
m_pPackage = m_pP->openPackage(_WS(filename), &error);
|
1 |
cycrow |
92 |
if ( !m_pPackage )
|
|
|
93 |
return false;
|
|
|
94 |
}
|
|
|
95 |
else
|
|
|
96 |
m_pPackage = base;
|
|
|
97 |
|
50 |
cycrow |
98 |
m_pPackage->adjustChanged(false);
|
175 |
cycrow |
99 |
m_pPackage->updateSigned(true);
|
1 |
cycrow |
100 |
this->UpdateChanged();
|
|
|
101 |
m_bLoading = true;
|
|
|
102 |
|
|
|
103 |
if ( m_pPackage->AnyFileType(FILETYPE_ADVERT) )
|
|
|
104 |
{
|
|
|
105 |
for ( C_File *f = m_pPackage->GetFirstFile(FILETYPE_ADVERT); f; f = m_pPackage->GetNextFile(f) )
|
|
|
106 |
{
|
224 |
cycrow |
107 |
f->setFullDir(_WS(System::IO::Path::GetTempPath()));
|
1 |
cycrow |
108 |
long size;
|
|
|
109 |
unsigned char *data = f->UncompressData(&size, 0);
|
|
|
110 |
if ( data && size )
|
|
|
111 |
{
|
129 |
cycrow |
112 |
if ( f->writeFilePointer(data, size) )
|
1 |
cycrow |
113 |
{
|
|
|
114 |
if ( !m_pDisplayFile )
|
|
|
115 |
m_pDisplayFile = f;
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
if ( f->GetCompressionType() != SPKCOMPRESS_NONE )
|
|
|
119 |
delete data;
|
|
|
120 |
}
|
|
|
121 |
}
|
|
|
122 |
}
|
|
|
123 |
|
170 |
cycrow |
124 |
if ( m_pPackage->icon() )
|
1 |
cycrow |
125 |
{
|
170 |
cycrow |
126 |
C_File *f = m_pPackage->icon();
|
197 |
cycrow |
127 |
f->setFilename(_WS(System::IO::Path::GetTempPath()) + L"/package_icon." + m_pPackage->iconExt());
|
|
|
128 |
f->setFullDir(_WS(System::IO::Path::GetTempPath()));
|
1 |
cycrow |
129 |
long size;
|
|
|
130 |
unsigned char *data = f->UncompressData(&size, 0);
|
|
|
131 |
if ( data && size )
|
|
|
132 |
{
|
129 |
cycrow |
133 |
f->writeFilePointer(data, size);
|
1 |
cycrow |
134 |
if ( f->GetCompressionType() != SPKCOMPRESS_NONE )
|
|
|
135 |
delete data;
|
|
|
136 |
}
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
this->RadioInstallBefore->Checked = true;
|
|
|
140 |
this->RadioInstallAfter->Checked = false;
|
|
|
141 |
this->RadioUninstallAfter->Checked = false;
|
|
|
142 |
this->RadioUninstallBefore->Checked = false;
|
|
|
143 |
this->UpdateView();
|
|
|
144 |
|
50 |
cycrow |
145 |
m_pPackage->adjustChanged(false);
|
1 |
cycrow |
146 |
|
|
|
147 |
m_bLoading = false;
|
|
|
148 |
|
|
|
149 |
return true;
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
void PackageForm::DoToolTips()
|
|
|
153 |
{
|
|
|
154 |
//tooltip1 for any controls with text to display
|
|
|
155 |
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");
|
|
|
156 |
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");
|
|
|
157 |
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");
|
|
|
158 |
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");
|
|
|
159 |
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");
|
|
|
160 |
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");
|
|
|
161 |
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");
|
|
|
162 |
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");
|
|
|
163 |
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");
|
|
|
164 |
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");
|
|
|
165 |
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");
|
|
|
166 |
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");
|
|
|
167 |
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");
|
|
|
168 |
|
|
|
169 |
// controls that need custom title texts using tags
|
|
|
170 |
this->ComboPluginType->Tag = "Plugin Type";
|
|
|
171 |
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");
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
void PackageForm::UpdateScriptType()
|
|
|
175 |
{
|
6 |
cycrow |
176 |
if ( this->ComboType->SelectedIndex == CSpkFile::SCRIPTTYPE_CUSTOM )
|
|
|
177 |
{
|
|
|
178 |
this->TextCustomType->Visible = true;
|
|
|
179 |
this->ComboType->Dock = Windows::Forms::DockStyle::Left;
|
|
|
180 |
if ( !m_bLoading )
|
214 |
cycrow |
181 |
((CSpkFile *)m_pPackage)->setScriptType(_WS(this->TextCustomType->Text));
|
1 |
cycrow |
182 |
}
|
|
|
183 |
else
|
|
|
184 |
{
|
|
|
185 |
this->TextCustomType->Visible = false;
|
|
|
186 |
this->ComboType->Dock = Windows::Forms::DockStyle::Fill;
|
|
|
187 |
}
|
|
|
188 |
}
|
|
|
189 |
void PackageForm::UpdateText()
|
|
|
190 |
{
|
46 |
cycrow |
191 |
const SPK::Package::CInstallText *pText = NULL;
|
|
|
192 |
|
1 |
cycrow |
193 |
this->TextText->Tag = 1;
|
|
|
194 |
if ( this->RadioInstallAfter->Checked || this->RadioInstallBefore->Checked )
|
46 |
cycrow |
195 |
pText = m_pPackage->installText();
|
1 |
cycrow |
196 |
else if ( this->RadioUninstallAfter->Checked || this->RadioUninstallBefore->Checked )
|
46 |
cycrow |
197 |
pText = m_pPackage->uninstallText();
|
1 |
cycrow |
198 |
else
|
|
|
199 |
{
|
|
|
200 |
this->ListLang->Enabled = false;
|
|
|
201 |
this->ButTextAdd->Enabled = false;
|
|
|
202 |
this->UpdateTextLang();
|
|
|
203 |
return;
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
this->ListLang->Enabled = true;
|
|
|
207 |
this->ButTextAdd->Enabled = true;
|
|
|
208 |
|
|
|
209 |
int selected = this->ListLang->SelectedIndex;
|
46 |
cycrow |
210 |
if ( selected >= 1 ) selected = Convert::ToInt32(this->ListLang->Text);
|
|
|
211 |
else selected = -1;
|
1 |
cycrow |
212 |
|
|
|
213 |
this->ListLang->Items->Clear();
|
|
|
214 |
this->ListLang->Items->Add("- Default -");
|
|
|
215 |
|
|
|
216 |
// add languages
|
46 |
cycrow |
217 |
for ( unsigned int i = 0; i < pText->count(); i++ ) {
|
|
|
218 |
int iLang = pText->language(i);
|
|
|
219 |
if ( iLang <= 0 ) continue;
|
|
|
220 |
this->ListLang->Items->Add(System::Convert::ToString(iLang));
|
1 |
cycrow |
221 |
}
|
|
|
222 |
|
|
|
223 |
if ( selected == -1 )
|
|
|
224 |
this->ListLang->SelectedIndex = 0;
|
|
|
225 |
else
|
|
|
226 |
this->ListLang->Text = Convert::ToString(selected);
|
46 |
cycrow |
227 |
|
1 |
cycrow |
228 |
if ( this->ListLang->SelectedIndex == -1 )
|
|
|
229 |
this->ListLang->SelectedIndex = 0;
|
|
|
230 |
|
|
|
231 |
this->UpdateTextLang();
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
void PackageForm::UpdateTextLang()
|
|
|
235 |
{
|
|
|
236 |
this->TextText->Tag = 1;
|
|
|
237 |
this->TextText->Enabled = false;
|
|
|
238 |
this->TextText->Text = "";
|
|
|
239 |
|
|
|
240 |
if ( this->ListLang->SelectedIndex >= 0 )
|
|
|
241 |
{
|
206 |
cycrow |
242 |
int lang = _WS(this->ListLang->Text).toInt();
|
|
|
243 |
Utils::WString desc;
|
46 |
cycrow |
244 |
if ( this->RadioInstallAfter->Checked ) desc = m_pPackage->installText(lang, false, false);
|
|
|
245 |
else if ( this->RadioInstallBefore->Checked ) desc = m_pPackage->installText(lang, true, false);
|
|
|
246 |
else if ( this->RadioUninstallAfter->Checked ) desc = m_pPackage->uninstallText(lang, false, false);
|
|
|
247 |
else if ( this->RadioUninstallBefore->Checked ) desc = m_pPackage->uninstallText(lang, true, false);
|
|
|
248 |
|
|
|
249 |
this->TextText->Text = _US(desc);
|
1 |
cycrow |
250 |
this->TextText->Enabled = true;
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
this->ButTextDel->Enabled = false;
|
|
|
254 |
if ( this->ListLang->SelectedIndex >= 1 )
|
|
|
255 |
this->ButTextDel->Enabled = true;
|
|
|
256 |
|
|
|
257 |
this->TextText->Tag = nullptr;
|
|
|
258 |
}
|
|
|
259 |
|
|
|
260 |
void PackageForm::UpdateWares()
|
|
|
261 |
{
|
|
|
262 |
CSpkFile *spk = (CSpkFile *)m_pPackage;
|
|
|
263 |
|
|
|
264 |
this->ListWares->Items->Clear();
|
|
|
265 |
for ( SWares *w = spk->GetWaresList()->First(); w; w = spk->GetWaresList()->Next() )
|
|
|
266 |
{
|
191 |
cycrow |
267 |
ListViewItem ^item = gcnew ListViewItem(_US(w->sID));
|
1 |
cycrow |
268 |
switch ( tolower(w->cType) )
|
|
|
269 |
{
|
|
|
270 |
case 'b':
|
|
|
271 |
item->SubItems->Add("Bio");
|
|
|
272 |
break;
|
|
|
273 |
case 'e':
|
|
|
274 |
item->SubItems->Add("Energy");
|
|
|
275 |
break;
|
|
|
276 |
case 'f':
|
|
|
277 |
item->SubItems->Add("Food");
|
|
|
278 |
break;
|
|
|
279 |
case 't':
|
|
|
280 |
item->SubItems->Add("Tech");
|
|
|
281 |
break;
|
|
|
282 |
case 'm':
|
|
|
283 |
item->SubItems->Add("Mineral");
|
|
|
284 |
break;
|
|
|
285 |
default:
|
|
|
286 |
item->SubItems->Add("Other");
|
|
|
287 |
}
|
|
|
288 |
item->SubItems->Add(System::Convert::ToString(w->iPrice));
|
|
|
289 |
switch ( w->iSize )
|
|
|
290 |
{
|
|
|
291 |
case 0:
|
|
|
292 |
item->SubItems->Add("Tiny Containers");
|
|
|
293 |
break;
|
|
|
294 |
case 1:
|
|
|
295 |
item->SubItems->Add("Small Containers (S)");
|
|
|
296 |
break;
|
|
|
297 |
case 2:
|
|
|
298 |
item->SubItems->Add("Medium Containers (M)");
|
|
|
299 |
break;
|
|
|
300 |
case 3:
|
|
|
301 |
item->SubItems->Add("Large Containers (L)");
|
|
|
302 |
break;
|
|
|
303 |
case 4:
|
|
|
304 |
item->SubItems->Add("Extra Large Containers (XL)");
|
|
|
305 |
break;
|
|
|
306 |
case 5:
|
|
|
307 |
item->SubItems->Add("Station Containers (ST)");
|
|
|
308 |
break;
|
|
|
309 |
default:
|
|
|
310 |
item->SubItems->Add("Other Containers");
|
|
|
311 |
}
|
|
|
312 |
|
|
|
313 |
item->SubItems->Add(System::Convert::ToString(w->iVolumn));
|
|
|
314 |
item->SubItems->Add(System::Convert::ToString(w->iNotority));
|
|
|
315 |
|
|
|
316 |
if ( w->iTextPage > 0 && w->iTextID > 0 )
|
|
|
317 |
item->SubItems->Add(System::Convert::ToString(w->iTextPage) + ", " + System::Convert::ToString(w->iTextID));
|
|
|
318 |
item->ImageIndex = 2;
|
|
|
319 |
this->ListWares->Items->Add(item);
|
|
|
320 |
}
|
|
|
321 |
this->ListWares->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
322 |
|
|
|
323 |
this->UpdateWareText();
|
175 |
cycrow |
324 |
m_pPackage->updateSigned(false);
|
1 |
cycrow |
325 |
this->UpdateChanged();
|
|
|
326 |
}
|
|
|
327 |
|
|
|
328 |
void PackageForm::UpdateWareText()
|
|
|
329 |
{
|
|
|
330 |
this->ListWareText->Items->Clear();
|
|
|
331 |
this->splitContainer1->Panel2Collapsed = true;
|
|
|
332 |
|
|
|
333 |
if ( this->ListWares->SelectedItems->Count )
|
|
|
334 |
{
|
216 |
cycrow |
335 |
SWares *w = ((CSpkFile *)m_pPackage)->findWare(_WS(this->ListWares->SelectedItems[0]->Text));
|
1 |
cycrow |
336 |
if ( w )
|
|
|
337 |
{
|
|
|
338 |
if ( w->iTextPage <= 0 && w->iTextID <= 0 )
|
|
|
339 |
{
|
|
|
340 |
this->ListWareText->Items->Clear();
|
|
|
341 |
this->splitContainer1->Panel2Collapsed = false;
|
|
|
342 |
for ( SWaresText *wt = w->lText.First(); wt; wt = w->lText.Next() )
|
|
|
343 |
{
|
|
|
344 |
ListViewItem ^item = gcnew ListViewItem(System::Convert::ToString(wt->iLang));
|
|
|
345 |
item->ImageIndex = 0;
|
191 |
cycrow |
346 |
item->SubItems->Add(_US(wt->sName));
|
|
|
347 |
item->SubItems->Add(_US(wt->sDesc));
|
1 |
cycrow |
348 |
this->ListWareText->Items->Add(item);
|
|
|
349 |
}
|
|
|
350 |
}
|
|
|
351 |
}
|
|
|
352 |
}
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
void PackageForm::UpdateView()
|
|
|
356 |
{
|
|
|
357 |
m_bLoading = true;
|
|
|
358 |
|
|
|
359 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(PackageForm::typeid));
|
|
|
360 |
|
|
|
361 |
this->LabelShipWarning->Visible = false;
|
50 |
cycrow |
362 |
this->TextName->Text = _US(m_pPackage->name());
|
|
|
363 |
this->TextAuthor->Text = _US(m_pPackage->author());
|
|
|
364 |
this->TextVersion->Text = _US(m_pPackage->version());
|
206 |
cycrow |
365 |
Utils::WString desc = m_pPackage->description();
|
|
|
366 |
desc = desc.findReplace(L"<br>", L"\n");
|
|
|
367 |
desc = desc.findReplace(L"<newline>", L"\n");
|
48 |
cycrow |
368 |
desc = desc.stripHtml();
|
|
|
369 |
this->TextDesc->Text = _US(desc);
|
1 |
cycrow |
370 |
|
|
|
371 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
372 |
{
|
|
|
373 |
CXspFile *xsp = (CXspFile *)m_pPackage;
|
217 |
cycrow |
374 |
this->TextShipID->Text = _US(xsp->shipID());
|
1 |
cycrow |
375 |
this->PanelShip->Show();
|
|
|
376 |
this->LabelShipWarning->Visible = true;
|
|
|
377 |
this->groupBox6->Visible = false;
|
|
|
378 |
|
217 |
cycrow |
379 |
this->TextShipData->Text = _US(xsp->shipData());
|
1 |
cycrow |
380 |
|
|
|
381 |
this->CheckShipID->Checked = xsp->IsExistingShip();
|
|
|
382 |
this->CheckExistingText->Checked = (xsp->GetOriginalDescription()) ? true : false;
|
|
|
383 |
if ( xsp->GetOriginalDescription() )
|
|
|
384 |
this->NumTextID->Value = xsp->GetOriginalDescription();
|
|
|
385 |
|
|
|
386 |
// shipyards
|
248 |
cycrow |
387 |
this->CheckSYArgon->Checked = xsp->isShipyard(ShipyardRace::Argon);
|
|
|
388 |
this->CheckSYBoron->Checked = xsp->isShipyard(ShipyardRace::Boron);
|
|
|
389 |
this->CheckSYTeladi->Checked = xsp->isShipyard(ShipyardRace::Teladi);
|
|
|
390 |
this->CheckSYParanid->Checked = xsp->isShipyard(ShipyardRace::Paranid);
|
|
|
391 |
this->CheckSYSplit->Checked = xsp->isShipyard(ShipyardRace::Split);
|
|
|
392 |
this->CheckSYFriend->Checked = xsp->isShipyard(ShipyardRace::Friend);
|
|
|
393 |
this->CheckSYPirate->Checked = xsp->isShipyard(ShipyardRace::Pirates);
|
|
|
394 |
this->CheckSYXenon->Checked = xsp->isShipyard(ShipyardRace::Xenon);
|
|
|
395 |
this->CheckSYTerran->Checked = xsp->isShipyard(ShipyardRace::Terran);
|
|
|
396 |
this->CheckSYATF->Checked = xsp->isShipyard(ShipyardRace::ATF);
|
|
|
397 |
this->CheckSYYaki->Checked = xsp->isShipyard(ShipyardRace::Yaki);
|
1 |
cycrow |
398 |
|
|
|
399 |
this->UpdateShipText();
|
|
|
400 |
this->UpdateShipPartList();
|
|
|
401 |
}
|
|
|
402 |
else if ( m_pPackage->GetType() == TYPE_SPK )
|
|
|
403 |
{
|
|
|
404 |
CSpkFile *spk = (CSpkFile *)m_pPackage;
|
|
|
405 |
|
|
|
406 |
this->ComboType->Text = "Custom";
|
|
|
407 |
this->ComboType->Enabled = false;
|
|
|
408 |
|
48 |
cycrow |
409 |
this->ComboPluginType->SelectedIndex = spk->pluginType();
|
1 |
cycrow |
410 |
|
|
|
411 |
if ( spk->IsLibrary() )
|
|
|
412 |
this->RadioTypeLibrary->Checked = true;
|
|
|
413 |
else if ( spk->IsCustomStart() )
|
|
|
414 |
this->RadioTypeStart->Checked = true;
|
|
|
415 |
else if ( spk->IsPackageUpdate() )
|
|
|
416 |
this->RadioTypeUpdate->Checked = true;
|
|
|
417 |
else if ( spk->IsPatch() )
|
|
|
418 |
this->RadioTypePatch->Checked = true;
|
|
|
419 |
else
|
|
|
420 |
{
|
|
|
421 |
this->RadioTypeScript->Checked = true;
|
|
|
422 |
this->ComboType->SelectedIndex = spk->GetScriptType();
|
|
|
423 |
this->ComboType->Enabled = true;
|
6 |
cycrow |
424 |
if ( this->ComboType->SelectedIndex == CSpkFile::SCRIPTTYPE_CUSTOM )
|
214 |
cycrow |
425 |
this->TextCustomType->Text = _US(spk->customScriptType(m_pP->GetLanguage()));
|
1 |
cycrow |
426 |
}
|
|
|
427 |
|
|
|
428 |
this->CheckOther->Checked = spk->IsAnotherMod();
|
|
|
429 |
this->TextOtherAuthor->Enabled = this->CheckOther->Checked;
|
|
|
430 |
this->TextOtherName->Enabled = this->CheckOther->Checked;
|
|
|
431 |
this->ButFromFile->Enabled = this->CheckOther->Checked;
|
|
|
432 |
|
|
|
433 |
if ( spk->IsAnotherMod() )
|
|
|
434 |
{
|
214 |
cycrow |
435 |
this->TextOtherAuthor->Text = _US(spk->otherAuthor());
|
|
|
436 |
this->TextOtherName->Text = _US(spk->otherName());
|
1 |
cycrow |
437 |
}
|
|
|
438 |
|
|
|
439 |
this->UpdateWares();
|
|
|
440 |
this->UpdateScriptType();
|
|
|
441 |
}
|
|
|
442 |
|
50 |
cycrow |
443 |
if ( !m_pPackage->creationDate().empty() ) {
|
204 |
cycrow |
444 |
int day = m_pPackage->creationDate().token(L"/", 1);
|
|
|
445 |
int month = m_pPackage->creationDate().token(L"/", 2);
|
|
|
446 |
int year = m_pPackage->creationDate().token(L"/", 3);
|
1 |
cycrow |
447 |
if ( month > 12 && day <= 12 ) { int temp = day; day = month; month = temp; }
|
|
|
448 |
if ( month < 1 ) month = 1;
|
|
|
449 |
if ( month > 12 ) month = 12;
|
|
|
450 |
if ( day < 1 ) day = 1;
|
|
|
451 |
if ( day > 31 ) day = 1;
|
|
|
452 |
if ( year < 1900 ) year += 2000;
|
|
|
453 |
try {
|
|
|
454 |
this->CreationDate->Value = DateTime(year, month, day);
|
|
|
455 |
} catch(System::ArgumentOutOfRangeException ^) {
|
|
|
456 |
this->CreationDate->Value = DateTime::Today;
|
|
|
457 |
}
|
|
|
458 |
}
|
|
|
459 |
else
|
|
|
460 |
this->CreationDate->Value = DateTime::Today;
|
|
|
461 |
|
131 |
cycrow |
462 |
this->CreationDate->Checked = true;
|
|
|
463 |
|
49 |
cycrow |
464 |
this->TextForum->Text = _US(m_pPackage->forumLink());
|
|
|
465 |
this->TextEmail->Text = _US(m_pPackage->email());
|
|
|
466 |
this->TextWebsite->Text = _US(m_pPackage->webSite());
|
|
|
467 |
this->TextWebAddress->Text = _US(m_pPackage->webAddress());
|
1 |
cycrow |
468 |
|
|
|
469 |
this->UpdateGamesList();
|
|
|
470 |
this->UpdateFileList();
|
|
|
471 |
this->UpdateMirrors();
|
|
|
472 |
this->UpdatePackageNames();
|
|
|
473 |
|
|
|
474 |
m_bSortingAsc = true;
|
|
|
475 |
m_iSortingCol = 1;
|
|
|
476 |
this->ListFiles->ListViewItemSorter = gcnew ListViewItemComparer(m_iSortingCol, !m_bSortingAsc);
|
|
|
477 |
|
|
|
478 |
this->UpdateDisplayPic();
|
|
|
479 |
this->UpdateDisplayIcon();
|
|
|
480 |
this->UpdateRatings();
|
|
|
481 |
this->UpdateText();
|
|
|
482 |
this->UpdateDependacies();
|
237 |
cycrow |
483 |
this->UpdateGlobals();
|
1 |
cycrow |
484 |
|
|
|
485 |
// delete the pages
|
|
|
486 |
if ( m_pPackage->GetType() != TYPE_XSP )
|
|
|
487 |
{
|
|
|
488 |
delete this->PageShip;
|
|
|
489 |
delete this->PageRaw;
|
|
|
490 |
delete this->PageShipComp;
|
|
|
491 |
this->PageShip = nullptr;
|
|
|
492 |
this->PageRaw = nullptr;
|
|
|
493 |
this->PageShipComp = nullptr;
|
|
|
494 |
this->PanelShip->Hide();
|
|
|
495 |
this->ToolCustomise->Visible = false;
|
|
|
496 |
}
|
|
|
497 |
else if ( m_pPackage->GetType() != TYPE_SPK )
|
|
|
498 |
{
|
|
|
499 |
delete this->PagePackage;
|
|
|
500 |
delete this->PageWares;
|
|
|
501 |
this->PageWares = nullptr;
|
|
|
502 |
this->PagePackage = nullptr;
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
m_bLoading = false;
|
|
|
506 |
}
|
|
|
507 |
|
|
|
508 |
void PackageForm::UpdateDependacies()
|
|
|
509 |
{
|
|
|
510 |
this->ListDep->Items->Clear();
|
|
|
511 |
for ( SNeededLibrary *nl = m_pPackage->GetNeededLibraries()->First(); nl; nl = m_pPackage->GetNeededLibraries()->Next() )
|
|
|
512 |
{
|
191 |
cycrow |
513 |
ListViewItem ^item = gcnew ListViewItem(_US(nl->sName));
|
|
|
514 |
item->SubItems->Add(_US(nl->sAuthor));
|
|
|
515 |
item->SubItems->Add(_US(nl->sMinVersion));
|
1 |
cycrow |
516 |
item->ImageIndex = 3;
|
|
|
517 |
this->ListDep->Items->Add(item);
|
|
|
518 |
}
|
|
|
519 |
this->ListDep->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
520 |
}
|
|
|
521 |
|
237 |
cycrow |
522 |
void PackageForm::UpdateGlobals()
|
|
|
523 |
{
|
|
|
524 |
this->listGlobals->Items->Clear();
|
|
|
525 |
auto& list = m_pPackage->getGlobals();
|
|
|
526 |
for (auto itr = list.begin(); itr != list.end(); itr++)
|
|
|
527 |
{
|
|
|
528 |
ListViewItem^ item = gcnew ListViewItem(_US((*itr)->str));
|
|
|
529 |
item->SubItems->Add(_US((*itr)->data));
|
|
|
530 |
item->ImageIndex = 3;
|
|
|
531 |
this->listGlobals->Items->Add(item);
|
|
|
532 |
}
|
|
|
533 |
}
|
|
|
534 |
|
1 |
cycrow |
535 |
void PackageForm::UpdateShipPartList()
|
|
|
536 |
{
|
|
|
537 |
if ( !m_pPackage )
|
|
|
538 |
return;
|
|
|
539 |
CXspFile *xsp = (CXspFile *)m_pPackage;
|
|
|
540 |
|
|
|
541 |
// first lets adjust out columns
|
|
|
542 |
int numColums = 1;
|
|
|
543 |
this->ListShipPart->Visible = true;
|
|
|
544 |
this->ListShipPart->Items->Clear();
|
|
|
545 |
switch ( this->ComboShipPart->SelectedIndex )
|
|
|
546 |
{
|
|
|
547 |
case 0: // componants
|
|
|
548 |
numColums = 3;
|
|
|
549 |
this->ColumnPart1->Text = "Section";
|
|
|
550 |
this->ColumnPart2->Text = "ID";
|
|
|
551 |
this->ColumnPart3->Text = "Data";
|
|
|
552 |
for ( SComponent *c = xsp->GetComponents()->First(); c; c = xsp->GetComponents()->Next() )
|
|
|
553 |
{
|
191 |
cycrow |
554 |
ListViewItem ^item = gcnew ListViewItem(_US(c->sSection));
|
1 |
cycrow |
555 |
item->ImageKey = "components";
|
191 |
cycrow |
556 |
item->SubItems->Add(_US(c->sSection2));
|
|
|
557 |
item->SubItems->Add(_US(c->sData));
|
1 |
cycrow |
558 |
this->ListShipPart->Items->Add(item);
|
|
|
559 |
}
|
|
|
560 |
break;
|
|
|
561 |
case 1: // dummies
|
|
|
562 |
numColums = 2;
|
|
|
563 |
this->ColumnPart1->Text = "Section";
|
|
|
564 |
this->ColumnPart2->Text = "Data";
|
|
|
565 |
for ( SDummy *d = xsp->GetDummies()->First(); d; d = xsp->GetDummies()->Next() )
|
|
|
566 |
{
|
191 |
cycrow |
567 |
ListViewItem ^item = gcnew ListViewItem(_US(d->sSection));
|
|
|
568 |
item->SubItems->Add(_US(d->sData));
|
1 |
cycrow |
569 |
item->ImageKey = "dummies";
|
|
|
570 |
this->ListShipPart->Items->Add(item);
|
|
|
571 |
}
|
|
|
572 |
break;
|
|
|
573 |
case 2: // Cockpit
|
|
|
574 |
numColums = 3;
|
|
|
575 |
this->ColumnPart1->Text = "ID";
|
|
|
576 |
this->ColumnPart2->Text = "Index";
|
|
|
577 |
this->ColumnPart3->Text = "Data";
|
|
|
578 |
for ( SCockpit *c = xsp->GetCockpits()->First(); c; c = xsp->GetCockpits()->Next() )
|
|
|
579 |
{
|
216 |
cycrow |
580 |
Utils::WString cName = c->sCockpit;
|
|
|
581 |
cName = cName.token(L";", -2);
|
|
|
582 |
while ( cName.right(1) == L";" )
|
191 |
cycrow |
583 |
cName.truncate(-1);
|
|
|
584 |
ListViewItem ^item = gcnew ListViewItem(_US(cName));
|
1 |
cycrow |
585 |
if ( c->iIndex == -1 )
|
|
|
586 |
item->SubItems->Add("<PACKAGE>");
|
|
|
587 |
else
|
|
|
588 |
item->SubItems->Add(Convert::ToString(c->iIndex));
|
191 |
cycrow |
589 |
item->SubItems->Add(_US(c->sCockpit));
|
1 |
cycrow |
590 |
item->ImageKey = "cockpit";
|
|
|
591 |
this->ListShipPart->Items->Add(item);
|
|
|
592 |
}
|
|
|
593 |
break;
|
|
|
594 |
case 3: // CutData
|
|
|
595 |
numColums = 1;
|
|
|
596 |
this->ColumnPart1->Text = "Cuts";
|
165 |
cycrow |
597 |
for(auto itr = xsp->getCutData().begin(); itr != xsp->getCutData().end(); itr++)
|
1 |
cycrow |
598 |
{
|
165 |
cycrow |
599 |
ListViewItem ^item = gcnew ListViewItem(_US((*itr)->str));
|
1 |
cycrow |
600 |
item->ImageKey = "cutdata";
|
|
|
601 |
this->ListShipPart->Items->Add(item);
|
|
|
602 |
}
|
|
|
603 |
break;
|
|
|
604 |
case 4: // Bodies
|
|
|
605 |
numColums = 2;
|
|
|
606 |
this->ColumnPart1->Text = "Section";
|
|
|
607 |
this->ColumnPart2->Text = "Bodies";
|
170 |
cycrow |
608 |
for(auto itr = xsp->getBodies().begin(); itr != xsp->getBodies().end(); itr++)
|
1 |
cycrow |
609 |
{
|
216 |
cycrow |
610 |
ListViewItem ^item = gcnew ListViewItem(_US((*itr)->str.token(L";", 1)));
|
|
|
611 |
item->SubItems->Add(_US((*itr)->str.tokens(L";", 2)));
|
1 |
cycrow |
612 |
item->ImageKey = "bodies";
|
|
|
613 |
this->ListShipPart->Items->Add(item);
|
|
|
614 |
}
|
|
|
615 |
break;
|
|
|
616 |
case 5: // Animations
|
|
|
617 |
numColums = 1;
|
|
|
618 |
this->ColumnPart1->Text = "Animations";
|
170 |
cycrow |
619 |
for(auto itr = xsp->getAnimations().begin(); itr != xsp->getAnimations().end(); itr++)
|
1 |
cycrow |
620 |
{
|
170 |
cycrow |
621 |
ListViewItem ^item = gcnew ListViewItem(_US((*itr)->str));
|
1 |
cycrow |
622 |
item->ImageKey = "animations";
|
|
|
623 |
this->ListShipPart->Items->Add(item);
|
|
|
624 |
}
|
|
|
625 |
break;
|
|
|
626 |
|
|
|
627 |
// dont know what we are supposed to be displaying
|
|
|
628 |
default:
|
|
|
629 |
this->ListShipPart->Visible = false;
|
|
|
630 |
}
|
|
|
631 |
|
|
|
632 |
this->ListShipPart->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
633 |
// adjust size of columns
|
|
|
634 |
if ( numColums < 3 )
|
|
|
635 |
this->ColumnPart3->Width = 0;
|
|
|
636 |
if ( numColums < 2 )
|
|
|
637 |
this->ColumnPart2->Width = 0;
|
|
|
638 |
}
|
|
|
639 |
|
|
|
640 |
void PackageForm::UpdateShipText()
|
|
|
641 |
{
|
|
|
642 |
CXspFile *xsp = (CXspFile *)m_pPackage;
|
|
|
643 |
|
|
|
644 |
this->ListShipText->Items->Clear();
|
|
|
645 |
|
|
|
646 |
for ( SText *t = xsp->GetTexts()->First(); t; t = xsp->GetTexts()->Next() )
|
|
|
647 |
{
|
|
|
648 |
ListViewItem ^item = gcnew ListViewItem(System::Convert::ToString(t->iId));
|
|
|
649 |
item->ImageIndex = 0;
|
191 |
cycrow |
650 |
item->SubItems->Add(_US(t->sName));
|
|
|
651 |
item->SubItems->Add(_US(t->sDesc));
|
1 |
cycrow |
652 |
this->ListShipText->Items->Add(item);
|
|
|
653 |
}
|
|
|
654 |
|
|
|
655 |
this->ListShipText->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
656 |
}
|
|
|
657 |
|
|
|
658 |
void PackageForm::UpdateDisplayPic()
|
|
|
659 |
{
|
|
|
660 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(PackageForm::typeid));
|
|
|
661 |
this->ButPicBack->Enabled = false;
|
|
|
662 |
this->ButPicNext->Enabled = false;
|
|
|
663 |
if ( m_pDisplayFile )
|
|
|
664 |
{
|
197 |
cycrow |
665 |
Utils::WString filePointer = m_pDisplayFile->filePointer();
|
|
|
666 |
filePointer = filePointer.findReplace(L"/", L"\\");
|
|
|
667 |
filePointer = filePointer.findReplace(L"\\\\", L"\\");
|
178 |
cycrow |
668 |
if ( System::IO::File::Exists(_US(filePointer)) )
|
1 |
cycrow |
669 |
{
|
178 |
cycrow |
670 |
Bitmap ^myBitmap = gcnew Bitmap(_US(filePointer));
|
1 |
cycrow |
671 |
if ( myBitmap )
|
|
|
672 |
this->DisplayPicture->Image = dynamic_cast<Image ^>(myBitmap);
|
|
|
673 |
}
|
|
|
674 |
this->ButPicDel->Enabled = true;
|
|
|
675 |
|
|
|
676 |
if ( m_pPackage->GetFirstFile(FILETYPE_ADVERT) != m_pDisplayFile )
|
|
|
677 |
this->ButPicBack->Enabled = true;
|
|
|
678 |
if ( m_pPackage->GetNextFile(m_pDisplayFile) )
|
|
|
679 |
this->ButPicNext->Enabled = true;
|
|
|
680 |
}
|
|
|
681 |
else
|
|
|
682 |
{
|
|
|
683 |
this->ButPicDel->Enabled = false;
|
|
|
684 |
this->DisplayPicture->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"DisplayPicture.Image")));
|
|
|
685 |
}
|
|
|
686 |
|
|
|
687 |
}
|
|
|
688 |
|
|
|
689 |
void PackageForm::UpdateDisplayIcon()
|
|
|
690 |
{
|
|
|
691 |
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(PackageForm::typeid));
|
|
|
692 |
|
|
|
693 |
m_pTabPage->ImageIndex = 0;
|
|
|
694 |
|
|
|
695 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
696 |
this->DisplayIcon->Image = this->imageList1->Images[1];
|
|
|
697 |
else
|
|
|
698 |
{
|
|
|
699 |
this->DisplayIcon->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"DisplayIcon.Image")));
|
|
|
700 |
|
|
|
701 |
int num = -1;
|
|
|
702 |
if ( m_pPackage->GetType() == TYPE_SPK )
|
|
|
703 |
{
|
|
|
704 |
CSpkFile *spk = (CSpkFile *)m_pPackage;
|
|
|
705 |
if ( spk->IsLibrary() )
|
|
|
706 |
num = 3;
|
|
|
707 |
else if ( spk->IsPackageUpdate() )
|
|
|
708 |
num = 6;
|
|
|
709 |
else if ( spk->IsPatch() )
|
|
|
710 |
num = 7;
|
|
|
711 |
else if ( spk->IsCustomStart() )
|
|
|
712 |
num = 8;
|
|
|
713 |
}
|
|
|
714 |
|
|
|
715 |
if ( num == -1 && m_pPackage->IsFakePatch() )
|
|
|
716 |
num = 2;
|
|
|
717 |
|
|
|
718 |
if ( num != -1 )
|
|
|
719 |
{
|
|
|
720 |
this->DisplayIcon->Image = this->imageList1->Images[num];
|
|
|
721 |
m_pTabPage->ImageIndex = num;
|
|
|
722 |
}
|
|
|
723 |
}
|
|
|
724 |
|
|
|
725 |
this->ButIconDel->Enabled = false;
|
|
|
726 |
|
170 |
cycrow |
727 |
if ( m_pPackage->icon() )
|
1 |
cycrow |
728 |
{
|
|
|
729 |
this->ButIconDel->Enabled = true;
|
197 |
cycrow |
730 |
Utils::WString filePointer = m_pPackage->icon()->filePointer();
|
|
|
731 |
filePointer = filePointer.findReplace(L"/", L"\\");
|
|
|
732 |
filePointer = filePointer.findReplace(L"\\\\", L"\\");
|
178 |
cycrow |
733 |
String ^file = _US(filePointer);
|
1 |
cycrow |
734 |
if ( System::IO::File::Exists(file) )
|
|
|
735 |
{
|
|
|
736 |
Bitmap ^myBitmap = gcnew Bitmap(file);
|
|
|
737 |
if ( myBitmap )
|
|
|
738 |
{
|
|
|
739 |
this->DisplayIcon->Image = dynamic_cast<Image ^>(myBitmap);
|
|
|
740 |
this->imageList1->Images->Add(file, myBitmap);
|
|
|
741 |
m_pTabPage->ImageIndex = this->imageList1->Images->IndexOfKey(file);
|
|
|
742 |
if ( m_pTabPage->ImageIndex == -1 )
|
|
|
743 |
m_pTabPage->ImageIndex = 0;
|
|
|
744 |
}
|
|
|
745 |
}
|
|
|
746 |
}
|
|
|
747 |
|
|
|
748 |
if ( m_pTabPage->ImageIndex == 0 )
|
|
|
749 |
{
|
|
|
750 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
751 |
m_pTabPage->ImageIndex = 1;
|
|
|
752 |
}
|
|
|
753 |
|
|
|
754 |
m_pMenuItem->Image = this->imageList1->Images[m_pTabPage->ImageIndex];
|
|
|
755 |
}
|
|
|
756 |
|
|
|
757 |
void PackageForm::UpdateGameVersion()
|
|
|
758 |
{
|
|
|
759 |
bool restoreLoad = m_bLoading;
|
|
|
760 |
m_bLoading = true;
|
|
|
761 |
|
|
|
762 |
ComboVersion->BeginUpdate();
|
|
|
763 |
ComboVersion->Items->Clear();
|
|
|
764 |
|
|
|
765 |
this->TextExactVersion->Hide();
|
|
|
766 |
|
|
|
767 |
SGameExe *exe = NULL;
|
|
|
768 |
if ( ButGame->ImageIndex >= 0 )
|
197 |
cycrow |
769 |
exe = m_pP->GetGameExe()->game((m_pPackage) ? ButGame->ImageIndex : -1);
|
1 |
cycrow |
770 |
if ( exe )
|
|
|
771 |
{
|
|
|
772 |
ComboVersion->Items->Add("Original");
|
|
|
773 |
for ( int i = 0; i < exe->lVersions.size(); i++ )
|
|
|
774 |
{
|
|
|
775 |
SGameExeVersion *v = exe->lVersions[i];
|
191 |
cycrow |
776 |
ComboVersion->Items->Add(_US(v->sName));
|
1 |
cycrow |
777 |
}
|
|
|
778 |
ComboVersion->Items->Add("Exact (Custom)");
|
|
|
779 |
ComboVersion->Enabled = true;
|
|
|
780 |
}
|
|
|
781 |
else
|
|
|
782 |
{
|
|
|
783 |
ComboVersion->Enabled = false;
|
|
|
784 |
}
|
|
|
785 |
|
|
|
786 |
|
|
|
787 |
ComboVersion->EndUpdate();
|
|
|
788 |
|
|
|
789 |
if ( !restoreLoad )
|
|
|
790 |
m_bLoading = false;
|
|
|
791 |
}
|
|
|
792 |
|
|
|
793 |
void PackageForm::UpdateRatings()
|
|
|
794 |
{
|
|
|
795 |
this->PicEase1->BackColor = System::Drawing::Color::Transparent;
|
|
|
796 |
this->PicEase2->BackColor = System::Drawing::Color::Transparent;
|
|
|
797 |
this->PicEase3->BackColor = System::Drawing::Color::Transparent;
|
|
|
798 |
this->PicEase4->BackColor = System::Drawing::Color::Transparent;
|
|
|
799 |
this->PicEase5->BackColor = System::Drawing::Color::Transparent;
|
|
|
800 |
|
|
|
801 |
this->PicChange1->BackColor = System::Drawing::Color::Transparent;
|
|
|
802 |
this->PicChange2->BackColor = System::Drawing::Color::Transparent;
|
|
|
803 |
this->PicChange3->BackColor = System::Drawing::Color::Transparent;
|
|
|
804 |
this->PicChange4->BackColor = System::Drawing::Color::Transparent;
|
|
|
805 |
this->PicChange5->BackColor = System::Drawing::Color::Transparent;
|
|
|
806 |
|
|
|
807 |
this->PicRec1->BackColor = System::Drawing::Color::Transparent;
|
|
|
808 |
this->PicRec2->BackColor = System::Drawing::Color::Transparent;
|
|
|
809 |
this->PicRec3->BackColor = System::Drawing::Color::Transparent;
|
|
|
810 |
this->PicRec4->BackColor = System::Drawing::Color::Transparent;
|
|
|
811 |
this->PicRec5->BackColor = System::Drawing::Color::Transparent;
|
|
|
812 |
|
46 |
cycrow |
813 |
if ( m_pPackage->easeOfUse() >= 1 )
|
1 |
cycrow |
814 |
this->PicEase1->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
815 |
if ( m_pPackage->easeOfUse() >= 2 )
|
1 |
cycrow |
816 |
this->PicEase2->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
817 |
if ( m_pPackage->easeOfUse() >= 3 )
|
1 |
cycrow |
818 |
this->PicEase3->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
819 |
if ( m_pPackage->easeOfUse() >= 4 )
|
1 |
cycrow |
820 |
this->PicEase4->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
821 |
if ( m_pPackage->easeOfUse() >= 5 )
|
1 |
cycrow |
822 |
this->PicEase5->BackColor = System::Drawing::Color::Red;
|
|
|
823 |
|
46 |
cycrow |
824 |
if ( m_pPackage->recommended() >= 1 )
|
1 |
cycrow |
825 |
this->PicRec1->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
826 |
if ( m_pPackage->recommended() >= 2 )
|
1 |
cycrow |
827 |
this->PicRec2->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
828 |
if ( m_pPackage->recommended() >= 3 )
|
1 |
cycrow |
829 |
this->PicRec3->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
830 |
if ( m_pPackage->recommended() >= 4 )
|
1 |
cycrow |
831 |
this->PicRec4->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
832 |
if ( m_pPackage->recommended() >= 5 )
|
1 |
cycrow |
833 |
this->PicRec5->BackColor = System::Drawing::Color::Red;
|
|
|
834 |
|
46 |
cycrow |
835 |
if ( m_pPackage->gameChanging() >= 1 )
|
1 |
cycrow |
836 |
this->PicChange1->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
837 |
if ( m_pPackage->gameChanging() >= 2 )
|
1 |
cycrow |
838 |
this->PicChange2->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
839 |
if ( m_pPackage->gameChanging() >= 3 )
|
1 |
cycrow |
840 |
this->PicChange3->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
841 |
if ( m_pPackage->gameChanging() >= 4 )
|
1 |
cycrow |
842 |
this->PicChange4->BackColor = System::Drawing::Color::Red;
|
46 |
cycrow |
843 |
if ( m_pPackage->gameChanging() >= 5 )
|
1 |
cycrow |
844 |
this->PicChange5->BackColor = System::Drawing::Color::Red;
|
|
|
845 |
|
46 |
cycrow |
846 |
if ( m_pPackage->easeOfUse() < 0 )
|
1 |
cycrow |
847 |
this->GroupEase->Text = "Ease of Use";
|
|
|
848 |
else
|
46 |
cycrow |
849 |
this->GroupEase->Text = "Ease of Use (" + System::Convert::ToString(m_pPackage->easeOfUse()) + ")";
|
1 |
cycrow |
850 |
|
46 |
cycrow |
851 |
if ( m_pPackage->gameChanging() < 0 )
|
1 |
cycrow |
852 |
this->GroupChange->Text = "Game Changing";
|
|
|
853 |
else
|
46 |
cycrow |
854 |
this->GroupChange->Text = "Game Changing (" + System::Convert::ToString(m_pPackage->gameChanging()) + ")";
|
1 |
cycrow |
855 |
|
46 |
cycrow |
856 |
if ( m_pPackage->recommended() < 0 )
|
1 |
cycrow |
857 |
this->GroupRec->Text = "Recommended";
|
|
|
858 |
else
|
46 |
cycrow |
859 |
this->GroupRec->Text = "Recommended (" + System::Convert::ToString(m_pPackage->recommended()) + ")";
|
1 |
cycrow |
860 |
}
|
|
|
861 |
|
|
|
862 |
void PackageForm::Setup()
|
|
|
863 |
{
|
|
|
864 |
m_bLoading = true;
|
|
|
865 |
|
|
|
866 |
this->ComboFileType->Items->Add("All Files");
|
|
|
867 |
for ( int i = 0; i < FILETYPE_MAX; i++ )
|
127 |
cycrow |
868 |
this->ComboFileType->Items->Add(_US(GetFileTypeString(i)));
|
1 |
cycrow |
869 |
this->ComboFileType->SelectedIndex = 0;
|
|
|
870 |
|
|
|
871 |
this->PanelShip->Hide();
|
|
|
872 |
|
|
|
873 |
m_bSortingAsc = true;
|
|
|
874 |
m_iSortingCol = 1;
|
|
|
875 |
|
|
|
876 |
this->ListFiles->ColumnClick += gcnew ColumnClickEventHandler(this, &Creator::PackageForm::SortList);
|
|
|
877 |
this->ListFiles->ItemChecked += gcnew ItemCheckedEventHandler(this, &PackageForm::Event_FileChecked);
|
|
|
878 |
|
|
|
879 |
this->ContextGames->Items->Clear();
|
|
|
880 |
|
|
|
881 |
this->ComboGameFilter->Items->Clear();
|
|
|
882 |
this->ToolGame->DropDownItems->Clear();
|
|
|
883 |
|
|
|
884 |
this->ComboGameFilter->Items->Add("- None -");
|
|
|
885 |
this->ComboGameFilter->Items->Add("- All Games -");
|
|
|
886 |
|
127 |
cycrow |
887 |
ToolStripItem ^newItem = this->ToolGame->DropDownItems->Add("- All Games -");
|
|
|
888 |
newItem->Tag = Convert::ToString(0);
|
|
|
889 |
newItem->Click += gcnew System::EventHandler(this, &PackageForm::SetGame_Selected);
|
|
|
890 |
|
|
|
891 |
newItem = this->ToolGame->DropDownItems->Add("------");
|
|
|
892 |
newItem->Enabled = false;
|
|
|
893 |
|
|
|
894 |
if (!_addGameItem)
|
|
|
895 |
{
|
|
|
896 |
_addGameItem = gcnew System::Windows::Forms::ToolStripMenuItem;
|
|
|
897 |
_addGameItem->Text = "Add Game";
|
|
|
898 |
}
|
|
|
899 |
this->ToolGame->DropDownItems->Add(_addGameItem);
|
|
|
900 |
|
|
|
901 |
if (!_removeGameItem)
|
|
|
902 |
{
|
|
|
903 |
_removeGameItem = gcnew System::Windows::Forms::ToolStripMenuItem;
|
|
|
904 |
_removeGameItem->Text = "Remove Game";
|
|
|
905 |
}
|
|
|
906 |
this->ToolGame->DropDownItems->Add(_removeGameItem);
|
|
|
907 |
|
|
|
908 |
newItem = this->ToolGame->DropDownItems->Add("------");
|
|
|
909 |
newItem->Enabled = false;
|
|
|
910 |
|
197 |
cycrow |
911 |
for ( int i = 0; i < m_pP->GetGameExe()->numGames(); i++ )
|
1 |
cycrow |
912 |
{
|
197 |
cycrow |
913 |
SGameExe *gameExe = m_pP->GetGameExe()->game(i);
|
1 |
cycrow |
914 |
if ( gameExe )
|
|
|
915 |
{
|
|
|
916 |
System::Windows::Forms::ToolStripMenuItem ^newItem = gcnew System::Windows::Forms::ToolStripMenuItem;
|
127 |
cycrow |
917 |
newItem->Text = _US(gameExe->sName);
|
1 |
cycrow |
918 |
newItem->Tag = Convert::ToString(i + 1);
|
126 |
cycrow |
919 |
if (i < this->imageListGames->Images->Count)
|
|
|
920 |
newItem->Image = this->imageListGames->Images[i];
|
1 |
cycrow |
921 |
newItem->Click += gcnew System::EventHandler(this, &PackageForm::ContextGame_Selected);
|
|
|
922 |
this->ContextGames->Items->Add(newItem);
|
|
|
923 |
|
|
|
924 |
System::Windows::Forms::ToolStripMenuItem ^newItem2 = gcnew System::Windows::Forms::ToolStripMenuItem;
|
127 |
cycrow |
925 |
newItem2->Text = _US(gameExe->sName);
|
1 |
cycrow |
926 |
newItem2->Tag = Convert::ToString(i + 1);
|
126 |
cycrow |
927 |
if (i < this->imageListGames->Images->Count)
|
|
|
928 |
newItem2->Image = this->imageListGames->Images[i];
|
1 |
cycrow |
929 |
newItem2->Click += gcnew System::EventHandler(this, &PackageForm::SetGame_Selected);
|
|
|
930 |
this->ToolGame->DropDownItems->Add(newItem2);
|
127 |
cycrow |
931 |
this->ComboGameFilter->Items->Add(_US(gameExe->sName));
|
1 |
cycrow |
932 |
|
127 |
cycrow |
933 |
newItem2 = gcnew System::Windows::Forms::ToolStripMenuItem;
|
|
|
934 |
newItem2->Text = _US(gameExe->sName);
|
|
|
935 |
newItem2->Tag = Convert::ToString(i + 1);
|
|
|
936 |
if (i < this->imageListGames->Images->Count)
|
|
|
937 |
newItem2->Image = this->imageListGames->Images[i];
|
|
|
938 |
newItem2->Click += gcnew System::EventHandler(this, &PackageForm::AddGame_Selected);
|
|
|
939 |
_addGameItem->DropDownItems->Add(newItem2);
|
|
|
940 |
|
|
|
941 |
newItem2 = gcnew System::Windows::Forms::ToolStripMenuItem;
|
|
|
942 |
newItem2->Text = _US(gameExe->sName);
|
|
|
943 |
newItem2->Tag = Convert::ToString(i + 1);
|
|
|
944 |
if (i < this->imageListGames->Images->Count)
|
|
|
945 |
newItem2->Image = this->imageListGames->Images[i];
|
|
|
946 |
newItem2->Click += gcnew System::EventHandler(this, &PackageForm::RemoveGame_Selected);
|
|
|
947 |
_removeGameItem->DropDownItems->Add(newItem2);
|
1 |
cycrow |
948 |
}
|
|
|
949 |
}
|
|
|
950 |
|
|
|
951 |
this->ComboGameFilter->SelectedIndex = 0;
|
|
|
952 |
|
|
|
953 |
this->ButGame->Text = "- Select Game -";
|
|
|
954 |
this->ButGameAdd->Enabled = false;
|
|
|
955 |
|
214 |
cycrow |
956 |
m_pTypeList->clear();
|
6 |
cycrow |
957 |
for ( int i = 0; i < CSpkFile::SCRIPTTYPE_MAX; i++ )
|
1 |
cycrow |
958 |
{
|
299 |
cycrow |
959 |
m_pTypeList->pushBack(CSpkFile::GetScriptTypeStringStatic(i, m_pP->GetLanguage()));
|
|
|
960 |
ComboType->Items->Add(_US(CSpkFile::GetScriptTypeStringStatic(i, m_pP->GetLanguage())));
|
1 |
cycrow |
961 |
}
|
|
|
962 |
|
|
|
963 |
this->CreationDate->Value = DateTime::Today;
|
|
|
964 |
|
|
|
965 |
m_bLoading = false;
|
|
|
966 |
}
|
|
|
967 |
|
|
|
968 |
void PackageForm::UpdateGamesList()
|
|
|
969 |
{
|
|
|
970 |
this->ListGames->Items->Clear();
|
|
|
971 |
for ( SGameCompat *game = m_pPackage->GetGameCompatabilityList()->First(); game; game = m_pPackage->GetGameCompatabilityList()->Next() ) {
|
182 |
cycrow |
972 |
ListViewItem ^item = gcnew ListViewItem(_US(m_pP->getGameNameFromType(game->iGame)));
|
1 |
cycrow |
973 |
item->ImageIndex = (game->iGame < 0) ? -1 : (game->iGame - 1);
|
46 |
cycrow |
974 |
if ( !game->sVersion.empty() ) {
|
182 |
cycrow |
975 |
item->SubItems->Add("Exact: " + _US(game->sVersion));
|
1 |
cycrow |
976 |
}
|
|
|
977 |
else {
|
182 |
cycrow |
978 |
item->SubItems->Add(_US(m_pP->getGameVersionFromType(game->iGame, game->iVersion, game->sVersion)));
|
1 |
cycrow |
979 |
}
|
|
|
980 |
item->Tag = game->iGame;
|
|
|
981 |
this->ListGames->Items->Add(item);
|
|
|
982 |
}
|
|
|
983 |
|
|
|
984 |
this->ListGames->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
985 |
}
|
|
|
986 |
|
|
|
987 |
void PackageForm::UpdateFileList()
|
|
|
988 |
{
|
|
|
989 |
this->ButRemoveFile->Enabled = false;
|
|
|
990 |
|
|
|
991 |
int pos = 0;
|
|
|
992 |
this->ListFiles->Items->Clear();
|
|
|
993 |
if ( m_pPackage ) {
|
|
|
994 |
for ( C_File *file = m_pPackage->GetFileList()->First(); file; file = m_pPackage->GetFileList()->Next() )
|
|
|
995 |
{
|
|
|
996 |
file->SetPos(pos++);
|
127 |
cycrow |
997 |
if (this->ComboGameFilter->SelectedIndex == 1)
|
|
|
998 |
{
|
|
|
999 |
if (file->game() > 0 && file->game() != 1 << 31)
|
1 |
cycrow |
1000 |
continue;
|
|
|
1001 |
}
|
127 |
cycrow |
1002 |
else if (this->ComboGameFilter->SelectedIndex > 0)
|
|
|
1003 |
{
|
|
|
1004 |
if (!(1 << (this->ComboGameFilter->SelectedIndex - 1) & file->game()))
|
|
|
1005 |
continue;
|
|
|
1006 |
}
|
1 |
cycrow |
1007 |
if ( this->ComboFileType->SelectedIndex == 0 || (this->ComboFileType->SelectedIndex - 1) == file->GetFileType() )
|
|
|
1008 |
this->AddFile(file);
|
|
|
1009 |
}
|
|
|
1010 |
((Form1 ^)this->MdiParent)->UpdateStatus();
|
|
|
1011 |
}
|
|
|
1012 |
|
|
|
1013 |
this->ListFiles->AutoResizeColumns(ColumnHeaderAutoResizeStyle::HeaderSize);
|
|
|
1014 |
}
|
|
|
1015 |
|
|
|
1016 |
void PackageForm::AddFile(C_File *file)
|
|
|
1017 |
{
|
|
|
1018 |
ListViewItem ^item = gcnew ListViewItem("");
|
|
|
1019 |
|
|
|
1020 |
if ( file->GetData() )
|
|
|
1021 |
{
|
178 |
cycrow |
1022 |
item->SubItems->Add(_US("<PACKAGE>/" + file->getNameDirectory(NULL)));
|
|
|
1023 |
item->SubItems->Add(_US(file->uncompressedSizeString()));
|
1 |
cycrow |
1024 |
}
|
|
|
1025 |
else
|
|
|
1026 |
{
|
178 |
cycrow |
1027 |
item->SubItems->Add(_US(file->fullFilename()));
|
|
|
1028 |
item->SubItems->Add(_US(SPK::GetSizeString(file->GetSize())));
|
1 |
cycrow |
1029 |
}
|
|
|
1030 |
|
|
|
1031 |
if ( file->IsFakePatch() )
|
|
|
1032 |
item->SubItems->Add("Mod (Fakepatch)");
|
|
|
1033 |
else
|
178 |
cycrow |
1034 |
item->SubItems->Add(_US(file->fileTypeString()));
|
1 |
cycrow |
1035 |
|
178 |
cycrow |
1036 |
if ( !file->dir().empty() )
|
|
|
1037 |
item->SubItems->Add(_US(file->dir()));
|
1 |
cycrow |
1038 |
else
|
|
|
1039 |
item->SubItems->Add("");
|
|
|
1040 |
|
|
|
1041 |
if ( file->IsSigned() )
|
|
|
1042 |
item->SubItems->Add("Yes");
|
|
|
1043 |
else
|
|
|
1044 |
item->SubItems->Add("No");
|
|
|
1045 |
|
127 |
cycrow |
1046 |
if ( !file->game() || file->game() == (1 << 31))
|
1 |
cycrow |
1047 |
item->SubItems->Add("All Games");
|
127 |
cycrow |
1048 |
else
|
|
|
1049 |
{
|
|
|
1050 |
if (file->game() & (1 << 31))
|
|
|
1051 |
{
|
197 |
cycrow |
1052 |
Utils::WString sGames = L"";
|
127 |
cycrow |
1053 |
for (int i = 0; i < 31; ++i)
|
|
|
1054 |
{
|
|
|
1055 |
int gameMask = 1 << i;
|
|
|
1056 |
if (file->game() & gameMask)
|
|
|
1057 |
{
|
197 |
cycrow |
1058 |
Utils::WString sGame;
|
|
|
1059 |
SGameExe *exe = _pPackages->GetGameExe()->game(i - 1);
|
127 |
cycrow |
1060 |
if (exe)
|
|
|
1061 |
sGame = exe->sName;
|
|
|
1062 |
else
|
197 |
cycrow |
1063 |
sGame = L"Game: " + Utils::WString::Number(i);
|
127 |
cycrow |
1064 |
|
|
|
1065 |
if (sGames.empty())
|
|
|
1066 |
sGames = sGame;
|
|
|
1067 |
else
|
197 |
cycrow |
1068 |
sGames = sGames + L", " + sGame;
|
127 |
cycrow |
1069 |
}
|
|
|
1070 |
}
|
|
|
1071 |
item->SubItems->Add(_US(sGames));
|
1 |
cycrow |
1072 |
}
|
127 |
cycrow |
1073 |
else
|
|
|
1074 |
{
|
197 |
cycrow |
1075 |
SGameExe *exe = _pPackages->GetGameExe()->game(file->game() - 1);
|
127 |
cycrow |
1076 |
if (exe) {
|
|
|
1077 |
item->SubItems->Add(_US(exe->sName));
|
|
|
1078 |
}
|
|
|
1079 |
else {
|
|
|
1080 |
item->SubItems->Add("Game: " + file->game());
|
|
|
1081 |
}
|
1 |
cycrow |
1082 |
}
|
|
|
1083 |
}
|
|
|
1084 |
|
191 |
cycrow |
1085 |
item->Tag = _US(Utils::WString::Number(file->GetPos()));
|
1 |
cycrow |
1086 |
if ( file->IsFakePatch() )
|
|
|
1087 |
item->ImageKey = "fakepatch";
|
|
|
1088 |
else
|
|
|
1089 |
item->ImageIndex = file->GetFileType();
|
|
|
1090 |
|
|
|
1091 |
item->Checked = file->IsShared();
|
|
|
1092 |
|
|
|
1093 |
this->ListFiles->Items->Add(item);
|
|
|
1094 |
}
|
|
|
1095 |
|
|
|
1096 |
void PackageForm::AddNewFile()
|
|
|
1097 |
{
|
|
|
1098 |
// add filters
|
|
|
1099 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
1100 |
|
|
|
1101 |
System::String ^filter;
|
|
|
1102 |
for ( int i = 0; i < FILETYPE_MAX; i++ )
|
|
|
1103 |
{
|
|
|
1104 |
if ( filter )
|
|
|
1105 |
filter += "|";
|
191 |
cycrow |
1106 |
filter += _US(GetFileTypeString(i));
|
1 |
cycrow |
1107 |
filter += "|";
|
|
|
1108 |
// add extensions
|
|
|
1109 |
switch ( i )
|
|
|
1110 |
{
|
|
|
1111 |
case FILETYPE_SCRIPT:
|
|
|
1112 |
case FILETYPE_UNINSTALL:
|
|
|
1113 |
case FILETYPE_MAP:
|
|
|
1114 |
case FILETYPE_TEXT:
|
|
|
1115 |
case FILETYPE_MISSION:
|
|
|
1116 |
filter += "*.pck;*.xml";
|
|
|
1117 |
break;
|
|
|
1118 |
|
|
|
1119 |
case FILETYPE_README:
|
|
|
1120 |
filter += "*.txt;*.doc;*.docx;*.pdf";
|
|
|
1121 |
break;
|
|
|
1122 |
|
|
|
1123 |
case FILETYPE_MOD:
|
|
|
1124 |
filter += "*.cat";
|
|
|
1125 |
break;
|
|
|
1126 |
|
|
|
1127 |
case FILETYPE_SOUND:
|
|
|
1128 |
filter += "*.wav";
|
|
|
1129 |
break;
|
|
|
1130 |
|
|
|
1131 |
case FILETYPE_SCREEN:
|
|
|
1132 |
case FILETYPE_ADVERT:
|
|
|
1133 |
filter += "*.jpg;*.png";
|
|
|
1134 |
break;
|
|
|
1135 |
|
|
|
1136 |
case FILETYPE_SHIPSCENE:
|
|
|
1137 |
case FILETYPE_COCKPITSCENE:
|
|
|
1138 |
filter += "*.pbd;*.bod";
|
|
|
1139 |
break;
|
|
|
1140 |
|
|
|
1141 |
case FILETYPE_SHIPMODEL:
|
|
|
1142 |
filter += "*.pbd;*.bod;*.bob;*.pbb";
|
|
|
1143 |
break;
|
|
|
1144 |
|
|
|
1145 |
default:
|
|
|
1146 |
filter += "*.*";
|
|
|
1147 |
}
|
|
|
1148 |
}
|
|
|
1149 |
ofd->Filter = filter;
|
|
|
1150 |
ofd->FilterIndex = 1;
|
|
|
1151 |
ofd->RestoreDirectory = true;
|
|
|
1152 |
ofd->Multiselect = true;
|
|
|
1153 |
ofd->Title = "Select File(s) to add to package";
|
|
|
1154 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1155 |
{
|
224 |
cycrow |
1156 |
Utils::WString dir;
|
1 |
cycrow |
1157 |
if ( C_File::DoesTypeHaveExtraDir(ofd->FilterIndex - 1) )
|
|
|
1158 |
{
|
|
|
1159 |
InputBox ^input = gcnew InputBox("Enter the directory to add files to", ((ofd->FilterIndex - 1) == FILETYPE_EXTRA) ? "PluginManager/Extras/$scriptname" : "");
|
|
|
1160 |
if ( input->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
224 |
cycrow |
1161 |
dir = _WS(input->GetInput());
|
1 |
cycrow |
1162 |
}
|
|
|
1163 |
array<System::String ^> ^fileArray = ofd->FileNames;
|
|
|
1164 |
for ( int i = 0; i < fileArray->Length; i++ )
|
|
|
1165 |
{
|
|
|
1166 |
System::String ^file = fileArray[i];
|
224 |
cycrow |
1167 |
FileType filetype = m_pP->adjustFileType(_WS(file), static_cast<FileType>(ofd->FilterIndex - 1));
|
|
|
1168 |
C_File *f = m_pPackage->addFile(_WS(file), dir, filetype, this->ComboGameFilter->SelectedIndex > 1 ? (1 << (this->ComboGameFilter->SelectedIndex - 1) | 1 << 31) : 0);
|
1 |
cycrow |
1169 |
if ( (ofd->FilterIndex - 1) == FILETYPE_MOD )
|
224 |
cycrow |
1170 |
m_pPackage->addFile(CFileIO(_WS(file)).changeFileExtension(L"dat"), dir, filetype);
|
1 |
cycrow |
1171 |
}
|
175 |
cycrow |
1172 |
m_pPackage->updateSigned(false);
|
1 |
cycrow |
1173 |
this->UpdateFileList();
|
|
|
1174 |
this->UpdateDisplayPic();
|
|
|
1175 |
this->UpdateChanged();
|
|
|
1176 |
}
|
|
|
1177 |
}
|
|
|
1178 |
|
|
|
1179 |
bool PackageForm::CheckSave()
|
|
|
1180 |
{
|
50 |
cycrow |
1181 |
if ( m_pPackage->name().empty() )
|
1 |
cycrow |
1182 |
{
|
|
|
1183 |
MessageBox::Show(this, "You must specify a package name", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1184 |
return false;
|
|
|
1185 |
}
|
50 |
cycrow |
1186 |
if ( m_pPackage->author().empty() )
|
1 |
cycrow |
1187 |
{
|
|
|
1188 |
MessageBox::Show(this, "You must specify an Author", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1189 |
return false;
|
|
|
1190 |
}
|
50 |
cycrow |
1191 |
if ( m_pPackage->version().empty() )
|
1 |
cycrow |
1192 |
{
|
|
|
1193 |
MessageBox::Show(this, "You must specify a version number", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1194 |
return false;
|
|
|
1195 |
}
|
|
|
1196 |
|
|
|
1197 |
if ( m_pPackage->GetType() == TYPE_SPK )
|
|
|
1198 |
{
|
|
|
1199 |
if ( ((CSpkFile *)m_pPackage)->IsPackageUpdate() )
|
|
|
1200 |
{
|
203 |
cycrow |
1201 |
SNeededLibrary *n = m_pPackage->findPackageNeeded(L"<package>", L"<author>");
|
1 |
cycrow |
1202 |
if ( !n )
|
203 |
cycrow |
1203 |
m_pPackage->addNeededLibrary(L"<package>", L"<author>", L"1.00");
|
|
|
1204 |
n = m_pPackage->findPackageNeeded(L"<package>", L"<author>");
|
1 |
cycrow |
1205 |
|
|
|
1206 |
if ( n )
|
|
|
1207 |
{
|
50 |
cycrow |
1208 |
if ( ((CSpkFile *)m_pPackage)->version().compareVersion(n->sMinVersion) != COMPARE_OLDER )
|
1 |
cycrow |
1209 |
{
|
50 |
cycrow |
1210 |
MessageBox::Show(this, "The depencay vesion (" + _US(n->sMinVersion) + ") is too high, it must be lower than the current version (" + _US(m_pPackage->version()) + ")", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
1 |
cycrow |
1211 |
return false;
|
|
|
1212 |
}
|
|
|
1213 |
}
|
|
|
1214 |
}
|
|
|
1215 |
else if ( ((CSpkFile *)m_pPackage)->IsCustomStart() )
|
|
|
1216 |
{
|
|
|
1217 |
if ( !((CSpkFile *)m_pPackage)->CheckValidCustomStart() )
|
|
|
1218 |
{
|
|
|
1219 |
MessageBox::Show(this, "For a custom start, you must include an initplayer script", "Invalid Entry", MessageBoxButtons::OK, MessageBoxIcon::Stop);
|
|
|
1220 |
return false;
|
|
|
1221 |
}
|
|
|
1222 |
}
|
|
|
1223 |
else if ( ((CSpkFile *)m_pPackage)->IsPatch() )
|
|
|
1224 |
{
|
214 |
cycrow |
1225 |
if ( ((CSpkFile *)m_pPackage)->otherAuthor().empty() || ((CSpkFile *)m_pPackage)->otherName().empty() )
|
1 |
cycrow |
1226 |
{
|
|
|
1227 |
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);
|
|
|
1228 |
return false;
|
|
|
1229 |
}
|
|
|
1230 |
}
|
|
|
1231 |
}
|
|
|
1232 |
|
|
|
1233 |
System::DateTime ^time = DateTime(this->CreationDate->Value);
|
214 |
cycrow |
1234 |
m_pPackage->setCreationDate(_WS(System::Convert::ToString(time->Day) + "/" + System::Convert::ToString(time->Month) + "/" + System::Convert::ToString(time->Year)));
|
1 |
cycrow |
1235 |
|
|
|
1236 |
return true;
|
|
|
1237 |
}
|
|
|
1238 |
|
|
|
1239 |
void PackageForm::Save()
|
|
|
1240 |
{
|
|
|
1241 |
if ( !this->CheckSave() )
|
|
|
1242 |
return;
|
|
|
1243 |
|
50 |
cycrow |
1244 |
if ( m_pPackage->filename().empty() )
|
1 |
cycrow |
1245 |
{
|
|
|
1246 |
this->SaveAs();
|
|
|
1247 |
return;
|
|
|
1248 |
}
|
|
|
1249 |
|
|
|
1250 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
1251 |
((CXspFile *)m_pPackage)->AdjustCockpits();
|
|
|
1252 |
|
50 |
cycrow |
1253 |
SaveDialog ^save = gcnew SaveDialog(m_pPackage, _US(m_pPackage->filename()));
|
1 |
cycrow |
1254 |
if ( save->ShowDialog(this) == Windows::Forms::DialogResult::Cancel )
|
|
|
1255 |
return;
|
|
|
1256 |
|
|
|
1257 |
this->UpdateFileList();
|
50 |
cycrow |
1258 |
m_pPackage->adjustChanged(false);
|
1 |
cycrow |
1259 |
this->UpdateChanged();
|
|
|
1260 |
|
|
|
1261 |
if ( m_pSettings->bGenerateUpdate )
|
134 |
cycrow |
1262 |
m_pPackage->createUpdateFile(CFileIO(m_pPackage->filename()).dir());
|
1 |
cycrow |
1263 |
|
50 |
cycrow |
1264 |
MessageBox::Show("Package: " + _US(m_pPackage->filename()) + "\nHas been saved!", "Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);
|
1 |
cycrow |
1265 |
}
|
|
|
1266 |
|
|
|
1267 |
void PackageForm::SaveAs()
|
|
|
1268 |
{
|
|
|
1269 |
if ( !this->CheckSave() )
|
|
|
1270 |
return;
|
|
|
1271 |
|
|
|
1272 |
SaveFileDialog ^ofd = gcnew SaveFileDialog();
|
|
|
1273 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
1274 |
ofd->Filter = "Ship Files (*.xsp)|*.xsp";
|
|
|
1275 |
else
|
|
|
1276 |
ofd->Filter = "Package Files (*.spk)|*.spk";
|
|
|
1277 |
ofd->AddExtension = true;
|
197 |
cycrow |
1278 |
Utils::WString filename = m_pPackage->filename();
|
170 |
cycrow |
1279 |
if (filename.empty())
|
203 |
cycrow |
1280 |
filename = m_pPackage->getAutosaveName();
|
197 |
cycrow |
1281 |
filename = filename.findReplace(L"/", L"\\");
|
170 |
cycrow |
1282 |
ofd->FileName = _US(filename);
|
1 |
cycrow |
1283 |
ofd->FilterIndex = 1;
|
|
|
1284 |
ofd->RestoreDirectory = true;
|
|
|
1285 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1286 |
{
|
197 |
cycrow |
1287 |
m_pPackage->setFilename(_WS(ofd->FileName));
|
1 |
cycrow |
1288 |
m_sFilename = ofd->FileName;
|
158 |
cycrow |
1289 |
m_pTabPage->Text = _US(CFileIO(m_pPackage->filename()).filename());
|
1 |
cycrow |
1290 |
m_pMenuItem->Text = m_pTabPage->Text;
|
|
|
1291 |
this->Save();
|
|
|
1292 |
}
|
|
|
1293 |
}
|
|
|
1294 |
|
|
|
1295 |
System::Void PackageForm::PackageForm_Closing(System::Object^ sender, CancelEventArgs^ e) {
|
50 |
cycrow |
1296 |
if ( m_pPackage->hasChanged() )
|
1 |
cycrow |
1297 |
{
|
|
|
1298 |
String ^name = m_pTabPage->Text;
|
|
|
1299 |
if ( name[name->Length - 1] == '*' )
|
|
|
1300 |
name = name->Remove(name->Length - 1);
|
|
|
1301 |
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);
|
|
|
1302 |
|
|
|
1303 |
if ( result == System::Windows::Forms::DialogResult::Cancel )
|
|
|
1304 |
{
|
|
|
1305 |
e->Cancel = true;
|
|
|
1306 |
return;
|
|
|
1307 |
}
|
|
|
1308 |
else if ( result == System::Windows::Forms::DialogResult::Yes )
|
|
|
1309 |
{
|
|
|
1310 |
if ( !this->CheckSave() )
|
|
|
1311 |
{
|
|
|
1312 |
e->Cancel = true;
|
|
|
1313 |
return;
|
|
|
1314 |
}
|
|
|
1315 |
|
50 |
cycrow |
1316 |
if ( m_pPackage->filename().empty() )
|
1 |
cycrow |
1317 |
{
|
|
|
1318 |
SaveFileDialog ^ofd = gcnew SaveFileDialog();
|
|
|
1319 |
if ( m_pPackage->GetType() == TYPE_XSP )
|
|
|
1320 |
ofd->Filter = "Ship Files (*.xsp)|*.xsp";
|
|
|
1321 |
else
|
|
|
1322 |
ofd->Filter = "Package Files (*.spk)|*.spk";
|
|
|
1323 |
ofd->FilterIndex = 1;
|
|
|
1324 |
ofd->RestoreDirectory = true;
|
|
|
1325 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
224 |
cycrow |
1326 |
m_pPackage->setFilename(_WS(ofd->FileName));
|
1 |
cycrow |
1327 |
else
|
|
|
1328 |
{
|
|
|
1329 |
e->Cancel = true;
|
|
|
1330 |
return;
|
|
|
1331 |
}
|
|
|
1332 |
}
|
|
|
1333 |
|
224 |
cycrow |
1334 |
if ( !m_pPackage->writeFile(m_pPackage->filename()) )
|
1 |
cycrow |
1335 |
{
|
|
|
1336 |
e->Cancel = true;
|
50 |
cycrow |
1337 |
MessageBox::Show("Unable to save package\n" + _US(m_pPackage->filename()), "Save Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
1 |
cycrow |
1338 |
return;
|
|
|
1339 |
}
|
|
|
1340 |
}
|
|
|
1341 |
}
|
|
|
1342 |
|
|
|
1343 |
delete m_pPackage;
|
|
|
1344 |
m_pPackage = NULL;
|
|
|
1345 |
}
|
|
|
1346 |
|
|
|
1347 |
void PackageForm::UpdateMirrors()
|
|
|
1348 |
{
|
|
|
1349 |
this->ListMirrors->Items->Clear();
|
273 |
cycrow |
1350 |
for (size_t i = 0; i < m_pPackage->getMaxWebMirrors(); i++ )
|
1 |
cycrow |
1351 |
{
|
162 |
cycrow |
1352 |
ListViewItem ^item = gcnew ListViewItem(_US(m_pPackage->getWebMirror(i)));
|
1 |
cycrow |
1353 |
this->ListMirrors->Items->Add(item);
|
|
|
1354 |
item->ImageIndex = 1;
|
|
|
1355 |
}
|
|
|
1356 |
|
|
|
1357 |
this->ListMirrors->AutoResizeColumns(ColumnHeaderAutoResizeStyle::ColumnContent);
|
|
|
1358 |
if ( this->ListMirrors->Columns[0]->Width < 100 )
|
|
|
1359 |
this->ListMirrors->Columns[0]->Width = 100;
|
|
|
1360 |
}
|
|
|
1361 |
|
|
|
1362 |
void PackageForm::UpdatePackageNames()
|
|
|
1363 |
{
|
|
|
1364 |
this->ListNames->Items->Clear();
|
170 |
cycrow |
1365 |
for(auto itr = m_pPackage->namesList()->begin(); itr != m_pPackage->namesList()->end(); itr++)
|
1 |
cycrow |
1366 |
{
|
170 |
cycrow |
1367 |
ListViewItem ^item = gcnew ListViewItem(Convert::ToString((*itr)->iLanguage));
|
|
|
1368 |
item->SubItems->Add(_US((*itr)->sName));
|
1 |
cycrow |
1369 |
item->ImageIndex = 0;
|
|
|
1370 |
this->ListNames->Items->Add(item);
|
|
|
1371 |
}
|
|
|
1372 |
this->ListNames->AutoResizeColumns(ColumnHeaderAutoResizeStyle::ColumnContent);
|
|
|
1373 |
if ( this->ListNames->Columns[0]->Width < 100 )
|
|
|
1374 |
this->ListNames->Columns[0]->Width = 100;
|
|
|
1375 |
if ( this->ListNames->Columns[1]->Width < 100 )
|
|
|
1376 |
this->ListNames->Columns[1]->Width = 100;
|
|
|
1377 |
}
|
|
|
1378 |
|
|
|
1379 |
void PackageForm::AddDisplayPic()
|
|
|
1380 |
{
|
|
|
1381 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
1382 |
ofd->Filter = "Display Images|*.gif;*.png;*.jpg";
|
|
|
1383 |
ofd->FilterIndex = 1;
|
|
|
1384 |
ofd->RestoreDirectory = true;
|
|
|
1385 |
ofd->Multiselect = true;
|
|
|
1386 |
ofd->Title = "Select the Display image to add";
|
|
|
1387 |
|
|
|
1388 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1389 |
{
|
|
|
1390 |
array<System::String ^> ^fileArray = ofd->FileNames;
|
|
|
1391 |
for ( int i = 0; i < fileArray->Length; i++ )
|
224 |
cycrow |
1392 |
m_pDisplayFile = m_pPackage->addFile(_WS(fileArray[i]), L"", FILETYPE_ADVERT);
|
1 |
cycrow |
1393 |
|
|
|
1394 |
this->UpdateDisplayPic();
|
|
|
1395 |
this->UpdateFileList();
|
|
|
1396 |
}
|
|
|
1397 |
}
|
|
|
1398 |
|
|
|
1399 |
void PackageForm::AddDisplayIcon()
|
|
|
1400 |
{
|
|
|
1401 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
1402 |
ofd->Filter = "Icon Files|*.ico;*.png;*.bmp";
|
|
|
1403 |
ofd->FilterIndex = 1;
|
|
|
1404 |
ofd->RestoreDirectory = true;
|
|
|
1405 |
ofd->Multiselect = false;
|
|
|
1406 |
ofd->Title = "Select the Icon file to add";
|
|
|
1407 |
|
|
|
1408 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1409 |
{
|
224 |
cycrow |
1410 |
Utils::WString file = _WS(ofd->FileName);
|
1 |
cycrow |
1411 |
C_File *icon = new C_File(file);
|
|
|
1412 |
if ( icon->ReadFromFile() )
|
224 |
cycrow |
1413 |
m_pPackage->setIcon(icon, CFileIO(file).extension());
|
1 |
cycrow |
1414 |
|
|
|
1415 |
this->UpdateDisplayIcon();
|
|
|
1416 |
this->UpdateChanged();
|
|
|
1417 |
}
|
|
|
1418 |
}
|
|
|
1419 |
|
|
|
1420 |
void PackageForm::SaveText()
|
|
|
1421 |
{
|
|
|
1422 |
if ( this->TextText->Text->Length )
|
|
|
1423 |
{
|
|
|
1424 |
if ( this->ListLang->SelectedIndex >= 0 )
|
|
|
1425 |
{
|
224 |
cycrow |
1426 |
int lang = _WS(this->ListLang->Text).toInt();
|
|
|
1427 |
if ( this->RadioInstallAfter->Checked ) m_pPackage->addInstallText(lang, false, _WS(this->TextText->Text));
|
|
|
1428 |
else if ( this->RadioInstallBefore->Checked ) m_pPackage->addInstallText(lang, true, _WS(this->TextText->Text));
|
|
|
1429 |
else if ( this->RadioUninstallBefore->Checked ) m_pPackage->addUninstallText(lang, true, _WS(this->TextText->Text));
|
|
|
1430 |
else if ( this->RadioUninstallAfter->Checked ) m_pPackage->addUninstallText(lang, false, _WS(this->TextText->Text));
|
1 |
cycrow |
1431 |
this->UpdateChanged();
|
|
|
1432 |
}
|
|
|
1433 |
}
|
|
|
1434 |
}
|
|
|
1435 |
|
|
|
1436 |
void PackageForm::LoadShipData()
|
|
|
1437 |
{
|
|
|
1438 |
OpenFileDialog ^ofd = gcnew OpenFileDialog();
|
|
|
1439 |
ofd->Filter = "All (*.cat, tships)|*.cat;tships.txt;tships.pck|TShips Files (tships.txt/pck)|tships.txt;tships.pck|Mod Files (*.cat)|*.cat";
|
|
|
1440 |
ofd->FilterIndex = 1;
|
|
|
1441 |
ofd->RestoreDirectory = true;
|
|
|
1442 |
ofd->Multiselect = false;
|
|
|
1443 |
ofd->Title = "Select the TShips/Mod file to load ship data from";
|
|
|
1444 |
|
|
|
1445 |
if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1446 |
{
|
|
|
1447 |
// if its a cat file, lets load the text
|
|
|
1448 |
Hashtable ^catText = gcnew Hashtable();
|
|
|
1449 |
|
|
|
1450 |
if ( String::Compare(IO::FileInfo(ofd->FileName).Extension, ".cat") == 0 )
|
|
|
1451 |
{
|
197 |
cycrow |
1452 |
Utils::WStringList readText;
|
224 |
cycrow |
1453 |
if ( m_pP->readTextPage(_WS(ofd->FileName), readText, false, 17) )
|
1 |
cycrow |
1454 |
{
|
182 |
cycrow |
1455 |
for(auto itr = readText.begin(); itr != readText.end(); itr++)
|
1 |
cycrow |
1456 |
{
|
182 |
cycrow |
1457 |
String ^key = _US((*itr)->str);
|
1 |
cycrow |
1458 |
if ( catText->ContainsKey(key) )
|
182 |
cycrow |
1459 |
catText[key] = _US((*itr)->data);
|
1 |
cycrow |
1460 |
else
|
182 |
cycrow |
1461 |
catText->Add(key, _US((*itr)->data));
|
1 |
cycrow |
1462 |
}
|
|
|
1463 |
}
|
|
|
1464 |
}
|
|
|
1465 |
|
217 |
cycrow |
1466 |
Utils::WStringList list;
|
224 |
cycrow |
1467 |
if (m_pP->loadShipData(_WS(ofd->FileName), list))
|
1 |
cycrow |
1468 |
{
|
|
|
1469 |
LoadShip ^ls = gcnew LoadShip();
|
182 |
cycrow |
1470 |
for(auto itr = list.begin(); itr != list.end(); itr++)
|
1 |
cycrow |
1471 |
{
|
217 |
cycrow |
1472 |
int tId = (*itr)->data.token(L";", 7).toInt();
|
1 |
cycrow |
1473 |
String ^name;
|
|
|
1474 |
if ( catText->ContainsKey(Convert::ToString(tId)) )
|
|
|
1475 |
name = Convert::ToString(catText[Convert::ToString(tId)]);
|
|
|
1476 |
else
|
|
|
1477 |
name = ((Form1 ^)this->MdiParent)->FindText(-1, 17, tId);
|
217 |
cycrow |
1478 |
String ^text = ((Form1 ^)this->MdiParent)->FindText(-1, 1266, (*itr)->data.token(L";", 46).toInt()) + " " + name;
|
|
|
1479 |
int variation = (*itr)->data.token(L";", 51).toInt();
|
1 |
cycrow |
1480 |
if ( variation )
|
|
|
1481 |
text = text + " " + ((Form1 ^)this->MdiParent)->FindText(-1, 17, 10000 + variation);
|
182 |
cycrow |
1482 |
ls->AddShip(_US((*itr)->str), text);
|
1 |
cycrow |
1483 |
}
|
|
|
1484 |
|
|
|
1485 |
if ( ls->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
|
|
|
1486 |
{
|
217 |
cycrow |
1487 |
Utils::WString data = list.findString(_WS(ls->GetData()));
|
182 |
cycrow |
1488 |
if (data.empty())
|
1 |
cycrow |
1489 |
{
|
217 |
cycrow |
1490 |
((CXspFile *)m_pPackage)->setShipData(data);
|
|
|
1491 |
if ( ((CXspFile *)m_pPackage)->shipID().empty() )
|
1 |
cycrow |
1492 |
{
|
217 |
cycrow |
1493 |
Utils::WString id = data.tokens(L";", -2);
|
226 |
cycrow |
1494 |
while ( id.right(1) == L";" )
|
182 |
cycrow |
1495 |
id.truncate((int)id.length() - 1);
|
217 |
cycrow |
1496 |
((CXspFile *)m_pPackage)->setShipID(id);
|
182 |
cycrow |
1497 |
this->TextShipID->Text = _US(id);
|
1 |
cycrow |
1498 |
}
|
|
|
1499 |
|
217 |
cycrow |
1500 |
((CXspFile *)m_pPackage)->setShipData(data);
|
182 |
cycrow |
1501 |
this->TextShipData->Text = _US(data);
|
217 |
cycrow |
1502 |
this->NumTextID->Value = data.token(L";", 7).toInt();
|
1 |
cycrow |
1503 |
this->UpdateChanged();
|
|
|
1504 |
}
|
|
|
1505 |
}
|
|
|
1506 |
}
|
|
|
1507 |
else
|
|
|
1508 |
MessageBox::Show(this, "Unable to find any ship entries, invalid/missing TShips?", "Error Loading", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
|
|
1509 |
}
|
|
|
1510 |
}
|
|
|
1511 |
|
|
|
1512 |
void PackageForm::EditShipParts(bool edit)
|
|
|
1513 |
{
|
|
|
1514 |
CXspFile *xsp = (CXspFile *)m_pPackage;
|
|
|
1515 |
switch ( this->ComboShipPart->SelectedIndex )
|
|
|
1516 |
{
|
|
|
1517 |
case 0:
|
|
|
1518 |
{
|
|
|
1519 |
AddShipPart ^component = gcnew AddShipPart((Form1 ^)this->MdiParent);
|
|
|
1520 |
component->SetComponent(edit);
|
|
|
1521 |
|
|
|
1522 |
if ( edit )
|
|
|
1523 |
{
|
|
|
1524 |
component->SetSection(m_pSelectedItem->Text);
|
|
|
1525 |
component->SetSection2(m_pSelectedItem->SubItems[1]->Text);
|
|
|
1526 |
component->SetData(m_pSelectedItem->SubItems[2]->Text);
|
|
|
1527 |
}
|
|
|
1528 |
|
|
|
1529 |
if ( component->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1530 |
{
|
|
|
1531 |
if ( edit )
|
216 |
cycrow |
1532 |
xsp->removeComponent(_WS(m_pSelectedItem->Text), _WS(m_pSelectedItem->SubItems[1]->Text), _WS(m_pSelectedItem->SubItems[2]->Text));
|
|
|
1533 |
xsp->addComponent(_WS(component->GetSection()), _WS(component->GetSection2()), _WS(component->GetData()));
|
1 |
cycrow |
1534 |
if ( !edit )
|
|
|
1535 |
this->UpdateShipPartList();
|
|
|
1536 |
else
|
|
|
1537 |
{
|
|
|
1538 |
m_pSelectedItem->Text = component->GetSection();
|
|
|
1539 |
m_pSelectedItem->SubItems[1]->Text = component->GetSection2();
|
|
|
1540 |
m_pSelectedItem->SubItems[2]->Text = component->GetData();
|
|
|
1541 |
}
|
|
|
1542 |
}
|
|
|
1543 |
}
|
|
|
1544 |
break;
|
|
|
1545 |
case 1:
|
|
|
1546 |
{
|
|
|
1547 |
AddShipPart ^dummy = gcnew AddShipPart((Form1 ^)this->MdiParent);
|
|
|
1548 |
dummy->SetDummy(edit);
|
|
|
1549 |
|
|
|
1550 |
if ( edit )
|
|
|
1551 |
{
|
|
|
1552 |
dummy->SetSection(m_pSelectedItem->Text);
|
|
|
1553 |
dummy->SetData(m_pSelectedItem->SubItems[1]->Text);
|
|
|
1554 |
}
|
|
|
1555 |
|
|
|
1556 |
if ( dummy->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1557 |
{
|
|
|
1558 |
if ( edit )
|
216 |
cycrow |
1559 |
xsp->removeDummy(_WS(m_pSelectedItem->Text), _WS(m_pSelectedItem->SubItems[1]->Text));
|
|
|
1560 |
xsp->addDummy(_WS(dummy->GetSection()), _WS(dummy->GetData()));
|
1 |
cycrow |
1561 |
if ( !edit )
|
|
|
1562 |
this->UpdateShipPartList();
|
|
|
1563 |
else
|
|
|
1564 |
{
|
|
|
1565 |
m_pSelectedItem->Text = dummy->GetSection();
|
|
|
1566 |
m_pSelectedItem->SubItems[1]->Text = dummy->GetData();
|
|
|
1567 |
}
|
|
|
1568 |
}
|
|
|
1569 |
}
|
|
|
1570 |
break;
|
|
|
1571 |
|
|
|
1572 |
case 2:
|
|
|
1573 |
{
|
|
|
1574 |
AddCockpit ^cockpit = gcnew AddCockpit();
|
|
|
1575 |
if ( edit )
|
191 |
cycrow |
1576 |
cockpit->SetEdit(m_pSelectedItem->Text, _US(_WS(m_pSelectedItem->SubItems[2]->Text).token(L";", 8)), _WS(m_pSelectedItem->SubItems[2]->Text).token(L";", 9).toInt());
|
1 |
cycrow |
1577 |
if ( cockpit->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1578 |
{
|
|
|
1579 |
if ( !edit )
|
|
|
1580 |
{
|
218 |
cycrow |
1581 |
xsp->newCockpit(_WS(cockpit->GetID()), _WS(cockpit->GetScene()), cockpit->GetMask());
|
1 |
cycrow |
1582 |
this->UpdateShipPartList();
|
|
|
1583 |
}
|
|
|
1584 |
else
|
|
|
1585 |
{
|
218 |
cycrow |
1586 |
xsp->editCockpit(_WS(cockpit->GetID()), _WS(cockpit->GetScene()), cockpit->GetMask());
|
|
|
1587 |
m_pSelectedItem->SubItems[2]->Text = _US(xsp->getCockpitData(_WS(cockpit->GetID())));
|
1 |
cycrow |
1588 |
}
|
|
|
1589 |
}
|
|
|
1590 |
}
|
|
|
1591 |
break;
|
|
|
1592 |
|
|
|
1593 |
case 3:
|
|
|
1594 |
{
|
|
|
1595 |
if ( edit )
|
|
|
1596 |
{
|
191 |
cycrow |
1597 |
InputBox ^input2 = gcnew InputBox("Enter the filename for cut id: " + _US(_WS(m_pSelectedItem->Text).token(L";", 1)), _US(_WS(m_pSelectedItem->Text).token(L";", 2)));
|
1 |
cycrow |
1598 |
if ( input2->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1599 |
{
|
216 |
cycrow |
1600 |
xsp->removeCutData(_WS(m_pSelectedItem->Text));
|
|
|
1601 |
xsp->addCutData(_WS(m_pSelectedItem->Text).token(L";", 1) + L"; " + _WS(input2->GetInput()));
|
1 |
cycrow |
1602 |
this->UpdateShipPartList();
|
|
|
1603 |
}
|
|
|
1604 |
}
|
|
|
1605 |
else
|
|
|
1606 |
{
|
|
|
1607 |
InputBox ^input = gcnew InputBox("Enter the cut id to add");
|
|
|
1608 |
if ( input->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1609 |
{
|
|
|
1610 |
InputBox ^input2 = gcnew InputBox("Enter the filename for cut id: " + input->GetInput());
|
|
|
1611 |
if ( input2->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1612 |
{
|
216 |
cycrow |
1613 |
xsp->addCutData(_WS(input->GetInput() + L"; " + input2->GetInput()));
|
1 |
cycrow |
1614 |
this->UpdateShipPartList();
|
|
|
1615 |
}
|
|
|
1616 |
}
|
|
|
1617 |
}
|
|
|
1618 |
}
|
|
|
1619 |
break;
|
|
|
1620 |
|
|
|
1621 |
case 4:
|
|
|
1622 |
{
|
|
|
1623 |
AddShipPart ^dummy = gcnew AddShipPart((Form1 ^)this->MdiParent);
|
|
|
1624 |
dummy->SetBodies(edit);
|
|
|
1625 |
|
|
|
1626 |
if ( edit )
|
|
|
1627 |
{
|
|
|
1628 |
dummy->SetSection(m_pSelectedItem->Text);
|
|
|
1629 |
dummy->SetData(m_pSelectedItem->SubItems[1]->Text);
|
|
|
1630 |
}
|
|
|
1631 |
|
|
|
1632 |
if ( dummy->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1633 |
{
|
|
|
1634 |
if ( edit )
|
224 |
cycrow |
1635 |
xsp->removeBodies(_WS(m_pSelectedItem->Text + ";" + m_pSelectedItem->SubItems[1]->Text));
|
|
|
1636 |
xsp->addBodies(_WS(dummy->GetSection() + ";" + dummy->GetData()));
|
1 |
cycrow |
1637 |
if ( !edit )
|
|
|
1638 |
this->UpdateShipPartList();
|
|
|
1639 |
else
|
|
|
1640 |
{
|
|
|
1641 |
m_pSelectedItem->Text = dummy->GetSection();
|
|
|
1642 |
m_pSelectedItem->SubItems[1]->Text = dummy->GetData();
|
|
|
1643 |
}
|
|
|
1644 |
}
|
|
|
1645 |
}
|
|
|
1646 |
break;
|
|
|
1647 |
|
|
|
1648 |
case 5:
|
|
|
1649 |
{
|
|
|
1650 |
InputBox ^input = gcnew InputBox("Enter the animation data to add", (!edit) ? "" : m_pSelectedItem->Text);
|
|
|
1651 |
input->Large();
|
|
|
1652 |
if ( input->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1653 |
{
|
|
|
1654 |
if ( edit )
|
216 |
cycrow |
1655 |
xsp->removeAnimation(_WS(m_pSelectedItem->Text));
|
224 |
cycrow |
1656 |
xsp->addAnimation(_WS(input->GetInput()));
|
1 |
cycrow |
1657 |
this->UpdateShipPartList();
|
|
|
1658 |
}
|
|
|
1659 |
}
|
|
|
1660 |
break;
|
|
|
1661 |
}
|
|
|
1662 |
}
|
|
|
1663 |
|
197 |
cycrow |
1664 |
void PackageForm::DropGetDirectories(String ^dir, Utils::WStringList *list, bool packages)
|
1 |
cycrow |
1665 |
{
|
|
|
1666 |
cli::array<String ^> ^dirList = IO::Directory::GetFileSystemEntries(dir);
|
|
|
1667 |
for ( int j = 0; j < dirList->Length; j++ )
|
|
|
1668 |
{
|
|
|
1669 |
if ( IO::DirectoryInfo(dirList[j]).Exists )
|
|
|
1670 |
this->DropGetDirectories(dirList[j], list, packages);
|
|
|
1671 |
else
|
|
|
1672 |
{
|
|
|
1673 |
if ( packages )
|
197 |
cycrow |
1674 |
list->pushBack(_WS(dirList[j]), L"-1");
|
1 |
cycrow |
1675 |
else
|
197 |
cycrow |
1676 |
list->pushBack(_WS(dirList[j]), Utils::WString::Number(SPK::GetAutomaticFiletype(_WS(dirList[j]), NULL,false)));
|
1 |
cycrow |
1677 |
}
|
|
|
1678 |
}
|
|
|
1679 |
}
|
|
|
1680 |
|
|
|
1681 |
void PackageForm::RemoveSelectedFiles()
|
|
|
1682 |
{
|
|
|
1683 |
CLinkList<C_File> removeFiles;
|
|
|
1684 |
for ( int i = 0; i < ListFiles->SelectedItems->Count; i++ )
|
|
|
1685 |
{
|
225 |
cycrow |
1686 |
int id = _WS(cli::safe_cast<System::String ^>(this->ListFiles->SelectedItems[i]->Tag)).toInt();
|
1 |
cycrow |
1687 |
C_File *file = m_pPackage->GetFileList()->Get(id);
|
|
|
1688 |
if ( m_pDisplayFile == file )
|
|
|
1689 |
m_pDisplayFile = NULL;
|
|
|
1690 |
removeFiles.push_back(file);
|
|
|
1691 |
}
|
|
|
1692 |
|
|
|
1693 |
if ( removeFiles.size() )
|
|
|
1694 |
{
|
|
|
1695 |
for ( C_File *f = removeFiles.First(); f; f = removeFiles.Next() )
|
172 |
cycrow |
1696 |
m_pPackage->removeFile(f);
|
175 |
cycrow |
1697 |
m_pPackage->updateSigned(false);
|
1 |
cycrow |
1698 |
this->UpdateFileList();
|
|
|
1699 |
this->UpdateDisplayPic();
|
|
|
1700 |
this->UpdateChanged();
|
|
|
1701 |
}
|
|
|
1702 |
|
|
|
1703 |
if ( !ListFiles->SelectedItems->Count )
|
|
|
1704 |
this->ButRemoveFile->Enabled = false;
|
|
|
1705 |
}
|
|
|
1706 |
|
|
|
1707 |
String ^PackageForm::ExtractImport(String ^file, String ^type)
|
|
|
1708 |
{
|
|
|
1709 |
if ( String::Compare(IO::FileInfo(file).Extension, ".xml") == 0 )
|
|
|
1710 |
return file;
|
|
|
1711 |
|
|
|
1712 |
if ( String::Compare(IO::FileInfo(file).Extension, ".pck") == 0 )
|
|
|
1713 |
{
|
224 |
cycrow |
1714 |
C_File F(_WS(file));
|
1 |
cycrow |
1715 |
F.UnPCKFile();
|
264 |
cycrow |
1716 |
if ( F.writeToFile(CPackages::tempDirectory() + L"/tmp.dat"))
|
|
|
1717 |
return _US(CPackages::tempDirectory() + L"/tmp.dat");
|
1 |
cycrow |
1718 |
}
|
|
|
1719 |
else if ( String::Compare(IO::FileInfo(file).Extension, ".cat") == 0 )
|
|
|
1720 |
{
|
|
|
1721 |
CCatFile cat;
|
224 |
cycrow |
1722 |
if ( cat.open(_WS(file), L"", CATREAD_CATDECRYPT, false) == CATERR_NONE )
|
1 |
cycrow |
1723 |
{
|
264 |
cycrow |
1724 |
if ( cat.extractFile(_WS("types\\" + type + L".pck"), CPackages::tempDirectory() + L"/tmp.dat"))
|
|
|
1725 |
return _US(CPackages::tempDirectory() + L"/tmp.dat");
|
1 |
cycrow |
1726 |
}
|
|
|
1727 |
}
|
|
|
1728 |
|
|
|
1729 |
return "";
|
|
|
1730 |
}
|
|
|
1731 |
|
94 |
cycrow |
1732 |
CGameDirectories *PackageForm::gameDirectories()
|
1 |
cycrow |
1733 |
{
|
94 |
cycrow |
1734 |
return ((Form1 ^)this->MdiParent)->gameDirectories();
|
1 |
cycrow |
1735 |
}
|
|
|
1736 |
|
|
|
1737 |
void PackageForm::ImportData(String ^file, int type)
|
|
|
1738 |
{
|
224 |
cycrow |
1739 |
CFileIO F(_WS(file));
|
52 |
cycrow |
1740 |
if ( !F.exists() )
|
1 |
cycrow |
1741 |
return;
|
|
|
1742 |
|
218 |
cycrow |
1743 |
std::vector<Utils::WString> lines;
|
173 |
cycrow |
1744 |
if(!F.readLines(lines))
|
1 |
cycrow |
1745 |
return;
|
|
|
1746 |
|
|
|
1747 |
LoadShip ^load = gcnew LoadShip();
|
|
|
1748 |
|
|
|
1749 |
int entryPos = 1;
|
|
|
1750 |
int dataPos = 1;
|
|
|
1751 |
int dataPos2 = 0;
|
|
|
1752 |
bool sections = false;
|
218 |
cycrow |
1753 |
Utils::WString section;
|
1 |
cycrow |
1754 |
switch ( type )
|
|
|
1755 |
{
|
|
|
1756 |
case 2:
|
|
|
1757 |
entryPos = 2;
|
|
|
1758 |
dataPos = 19;
|
|
|
1759 |
load->Cockpits();
|
|
|
1760 |
break;
|
|
|
1761 |
case 3:
|
|
|
1762 |
dataPos2 = 2;
|
|
|
1763 |
load->CutData();
|
|
|
1764 |
break;
|
|
|
1765 |
case 4:
|
|
|
1766 |
sections = true;
|
|
|
1767 |
entryPos = 2;
|
|
|
1768 |
load->Bodies();
|
|
|
1769 |
break;
|
|
|
1770 |
case 1:
|
|
|
1771 |
sections = true;
|
|
|
1772 |
entryPos = 2;
|
|
|
1773 |
dataPos = -1;
|
|
|
1774 |
load->Dummies();
|
|
|
1775 |
break;
|
|
|
1776 |
case 0:
|
|
|
1777 |
sections = true;
|
|
|
1778 |
entryPos = 2;
|
|
|
1779 |
dataPos = -1;
|
|
|
1780 |
load->Components();
|
|
|
1781 |
break;
|
|
|
1782 |
}
|
|
|
1783 |
|
|
|
1784 |
int entries2 = 0;
|
|
|
1785 |
int entries = -1;
|
218 |
cycrow |
1786 |
Utils::WStringList list;
|
|
|
1787 |
Utils::WString data;
|
1 |
cycrow |
1788 |
int e = 0;
|
173 |
cycrow |
1789 |
for(auto itr = lines.begin(); itr != lines.end(); itr++)
|
1 |
cycrow |
1790 |
{
|
218 |
cycrow |
1791 |
Utils::WString str = itr->remove(9).remove('\r');
|
173 |
cycrow |
1792 |
str = str.removeFirstSpace();
|
|
|
1793 |
if (str.empty())
|
1 |
cycrow |
1794 |
continue;
|
173 |
cycrow |
1795 |
if (str[0] == '/')
|
1 |
cycrow |
1796 |
continue;
|
|
|
1797 |
|
|
|
1798 |
if ( entries == -1 || (entries <= 0 && sections) )
|
|
|
1799 |
{
|
218 |
cycrow |
1800 |
entries = str.token(L";", entryPos).toInt();
|
1 |
cycrow |
1801 |
if ( sections )
|
|
|
1802 |
{
|
218 |
cycrow |
1803 |
section = str.token(L";", 1);
|
173 |
cycrow |
1804 |
load->AddGroup(_US(section));
|
1 |
cycrow |
1805 |
}
|
|
|
1806 |
}
|
|
|
1807 |
else
|
|
|
1808 |
{
|
|
|
1809 |
if ( type == 4 )
|
|
|
1810 |
{
|
218 |
cycrow |
1811 |
std::vector<Utils::WString> strs;
|
|
|
1812 |
if(str.tokenise(L";", strs))
|
1 |
cycrow |
1813 |
{
|
218 |
cycrow |
1814 |
for (size_t i = 0; i < strs.size(); i++ )
|
1 |
cycrow |
1815 |
{
|
173 |
cycrow |
1816 |
strs[i].removeFirstSpace();
|
|
|
1817 |
if ( strs[i].empty() ) continue;
|
218 |
cycrow |
1818 |
Utils::WString id = strs[i].token(L";", dataPos);
|
173 |
cycrow |
1819 |
load->AddShip(_US(id), "");
|
218 |
cycrow |
1820 |
list.pushBack(id, Utils::WString::Number(e) + L" " + section + L";" + strs[i]);
|
1 |
cycrow |
1821 |
++e;
|
|
|
1822 |
--entries;
|
|
|
1823 |
}
|
|
|
1824 |
}
|
|
|
1825 |
}
|
|
|
1826 |
else if ( type == 0 )
|
|
|
1827 |
{
|
|
|
1828 |
if ( entries2 )
|
|
|
1829 |
{
|
173 |
cycrow |
1830 |
load->AddShip(_US(data), _US(str));
|
218 |
cycrow |
1831 |
list.pushBack(data, section + L";" + data + L";" + str);
|
1 |
cycrow |
1832 |
--entries2;
|
|
|
1833 |
}
|
|
|
1834 |
else
|
|
|
1835 |
{
|
218 |
cycrow |
1836 |
data = str.token(L";", 1);
|
|
|
1837 |
entries2 = str.token(L";", 2).toInt();
|
1 |
cycrow |
1838 |
++e;
|
|
|
1839 |
--entries;
|
|
|
1840 |
}
|
|
|
1841 |
}
|
|
|
1842 |
else
|
|
|
1843 |
{
|
218 |
cycrow |
1844 |
Utils::WString id;
|
1 |
cycrow |
1845 |
if ( dataPos == -1 )
|
173 |
cycrow |
1846 |
id = str;
|
1 |
cycrow |
1847 |
else
|
218 |
cycrow |
1848 |
id = str.token(L";", dataPos);
|
1 |
cycrow |
1849 |
|
|
|
1850 |
if ( dataPos2 )
|
218 |
cycrow |
1851 |
load->AddShip(_US(id), _US(str.token(L";", dataPos2)));
|
1 |
cycrow |
1852 |
else
|
173 |
cycrow |
1853 |
load->AddShip(_US(id), "");
|
1 |
cycrow |
1854 |
if ( sections )
|
218 |
cycrow |
1855 |
list.pushBack(id, Utils::WString::Number(e) + L" " + section + L";" + str);
|
1 |
cycrow |
1856 |
else
|
218 |
cycrow |
1857 |
list.pushBack(id, Utils::WString::Number(e) + L" " + str);
|
1 |
cycrow |
1858 |
++e;
|
|
|
1859 |
--entries;
|
|
|
1860 |
}
|
|
|
1861 |
}
|
|
|
1862 |
}
|
|
|
1863 |
|
|
|
1864 |
if ( load->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1865 |
{
|
170 |
cycrow |
1866 |
for(auto itr = load->GetDataList()->begin(); itr != load->GetDataList()->end(); itr++)
|
1 |
cycrow |
1867 |
{
|
216 |
cycrow |
1868 |
Utils::WString data = list.findString((*itr)->str);
|
173 |
cycrow |
1869 |
if (!data.empty())
|
1 |
cycrow |
1870 |
{
|
|
|
1871 |
switch ( type )
|
|
|
1872 |
{
|
|
|
1873 |
case 0:
|
216 |
cycrow |
1874 |
((CXspFile *)m_pPackage)->addComponent(data.token(L";", 1), data.token(L";", 2), data.tokens(L";", 3));
|
1 |
cycrow |
1875 |
break;
|
|
|
1876 |
case 2:
|
216 |
cycrow |
1877 |
((CXspFile *)m_pPackage)->addCockpit(data.tokens(L" ", 2), 0, -1, data.token(L" ", 1).toInt());
|
1 |
cycrow |
1878 |
break;
|
|
|
1879 |
case 3:
|
216 |
cycrow |
1880 |
((CXspFile *)m_pPackage)->addCutData(data.tokens(L" ", 2));
|
1 |
cycrow |
1881 |
break;
|
|
|
1882 |
case 4:
|
216 |
cycrow |
1883 |
((CXspFile *)m_pPackage)->addBodies(data.tokens(L" ", 2));
|
1 |
cycrow |
1884 |
break;
|
|
|
1885 |
case 1:
|
216 |
cycrow |
1886 |
((CXspFile *)m_pPackage)->addDummy(data.tokens(L" ", 2).token(L";", 1), data.tokens(L" ", 2).tokens(L";", 2));
|
1 |
cycrow |
1887 |
break;
|
|
|
1888 |
}
|
|
|
1889 |
}
|
|
|
1890 |
}
|
|
|
1891 |
|
|
|
1892 |
this->UpdateShipPartList();
|
|
|
1893 |
this->UpdateChanged();
|
|
|
1894 |
}
|
|
|
1895 |
}
|
|
|
1896 |
|
|
|
1897 |
void PackageForm::ImportAnimations(String ^file)
|
|
|
1898 |
{
|
224 |
cycrow |
1899 |
CFileIO F(_WS(file));
|
52 |
cycrow |
1900 |
if ( !F.exists() )
|
1 |
cycrow |
1901 |
return;
|
|
|
1902 |
|
212 |
cycrow |
1903 |
Utils::WStringList lines;
|
170 |
cycrow |
1904 |
if(!F.readLines(lines))
|
1 |
cycrow |
1905 |
return;
|
|
|
1906 |
|
212 |
cycrow |
1907 |
Utils::WStringList lOut;
|
170 |
cycrow |
1908 |
if ( CXspFile::ReadAnimations(lines, lOut, 0) )
|
1 |
cycrow |
1909 |
{
|
|
|
1910 |
LoadShip ^load = gcnew LoadShip();
|
|
|
1911 |
load->Animations();
|
170 |
cycrow |
1912 |
for(auto itr = lOut.begin(); itr != lOut.end(); itr++)
|
|
|
1913 |
load->AddShip(_US((*itr)->str), "");
|
1 |
cycrow |
1914 |
|
|
|
1915 |
if ( load->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1916 |
{
|
170 |
cycrow |
1917 |
((CXspFile *)m_pPackage)->addAnimation(*load->GetDataList());
|
1 |
cycrow |
1918 |
this->UpdateShipPartList();
|
|
|
1919 |
this->UpdateChanged();
|
|
|
1920 |
}
|
|
|
1921 |
}
|
|
|
1922 |
}
|
|
|
1923 |
|
237 |
cycrow |
1924 |
void PackageForm::EditGlobal()
|
|
|
1925 |
{
|
|
|
1926 |
AddGlobal^ global = gcnew AddGlobal();
|
|
|
1927 |
global->SetEdit(m_pSelectedItem->Text, m_pSelectedItem->SubItems[1]->Text);
|
|
|
1928 |
|
|
|
1929 |
if (global->ShowDialog(this) == Windows::Forms::DialogResult::OK)
|
|
|
1930 |
{
|
|
|
1931 |
m_pPackage->removeGlobal(_WS(global->GetName()));
|
|
|
1932 |
m_pPackage->addGlobal(_WS(global->GetName()), _WS(global->GetData()));
|
|
|
1933 |
|
|
|
1934 |
this->UpdateGlobals();
|
|
|
1935 |
this->UpdateChanged();
|
|
|
1936 |
}
|
|
|
1937 |
|
|
|
1938 |
this->UpdateDependacies();
|
|
|
1939 |
this->UpdateChanged();
|
|
|
1940 |
}
|
|
|
1941 |
|
|
|
1942 |
void PackageForm::AddNewGlobal()
|
|
|
1943 |
{
|
|
|
1944 |
AddGlobal^ global = gcnew AddGlobal();
|
|
|
1945 |
if (global->ShowDialog(this) == Windows::Forms::DialogResult::OK)
|
|
|
1946 |
{
|
|
|
1947 |
m_pPackage->addGlobal(_WS(global->GetName()), _WS(global->GetData()));
|
|
|
1948 |
this->UpdateGlobals();
|
|
|
1949 |
this->UpdateChanged();
|
|
|
1950 |
}
|
|
|
1951 |
}
|
|
|
1952 |
|
1 |
cycrow |
1953 |
void PackageForm::EditDepend()
|
|
|
1954 |
{
|
|
|
1955 |
AddDepend ^depend = gcnew AddDepend();
|
|
|
1956 |
depend->SetEdit(m_pSelectedItem->Text, m_pSelectedItem->SubItems[1]->Text, m_pSelectedItem->SubItems[2]->Text);
|
|
|
1957 |
|
|
|
1958 |
bool builtin = false;
|
|
|
1959 |
if ( String::Compare("<package>", m_pSelectedItem->Text) == 0 && String::Compare("<author>", m_pSelectedItem->SubItems[1]->Text) == 0 )
|
|
|
1960 |
{
|
|
|
1961 |
builtin = true;
|
|
|
1962 |
depend->BuiltIn();
|
|
|
1963 |
}
|
|
|
1964 |
|
|
|
1965 |
if ( depend->ShowDialog(this) == Windows::Forms::DialogResult::OK )
|
|
|
1966 |
{
|
|
|
1967 |
if ( builtin )
|
|
|
1968 |
{
|
203 |
cycrow |
1969 |
SNeededLibrary *ns = m_pPackage->findPackageNeeded(L"<package>", L"<author>");
|
1 |
cycrow |
1970 |
if ( ns )
|
204 |
cycrow |
1971 |
ns->sMinVersion = _WS(depend->GetVersion());
|
1 |
cycrow |
1972 |
}
|
|
|
1973 |
else
|
|
|
1974 |
{
|
203 |
cycrow |
1975 |
m_pPackage->removePackageNeeded(_WS(m_pSelectedItem->Text), _WS(m_pSelectedItem->SubItems[1]->Text));
|
204 |
cycrow |
1976 |
m_pPackage->addNeededLibrary(_WS(depend->GetName()), _WS(depend->GetAuthor()), _WS(depend->GetVersion()));
|
1 |
cycrow |
1977 |
}
|
|
|
1978 |
this->UpdateDependacies();
|
|
|
1979 |
this->UpdateChanged();
|
|
|
1980 |
}
|
|
|
1981 |
}
|
127 |
cycrow |
1982 |
|
|
|
1983 |
System::Void PackageForm::SetGame_Selected(System::Object^ sender, System::EventArgs^ e)
|
|
|
1984 |
{
|
|
|
1985 |
System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
|
|
|
1986 |
|
|
|
1987 |
int done = 0;
|
|
|
1988 |
if (ListFiles->SelectedItems->Count)
|
|
|
1989 |
{
|
|
|
1990 |
for (int i = 0; i < ListFiles->SelectedItems->Count; i++)
|
|
|
1991 |
{
|
224 |
cycrow |
1992 |
int id = _WS(cli::safe_cast<System::String ^>(this->ListFiles->SelectedItems[i]->Tag)).toInt();
|
127 |
cycrow |
1993 |
C_File *file = m_pPackage->GetFileList()->Get(id);
|
|
|
1994 |
if (file) {
|
|
|
1995 |
int iGame = Convert::ToInt32(item->Tag);
|
|
|
1996 |
if(!iGame)
|
|
|
1997 |
file->setGame(0);
|
|
|
1998 |
else
|
|
|
1999 |
file->setGame(1 << 31 | 1 << iGame);
|
|
|
2000 |
++done;
|
|
|
2001 |
}
|
|
|
2002 |
}
|
|
|
2003 |
}
|
|
|
2004 |
|
|
|
2005 |
if (done) {
|
|
|
2006 |
this->UpdateFileList();
|
|
|
2007 |
this->UpdateChanged();
|
|
|
2008 |
}
|
|
|
2009 |
}
|
|
|
2010 |
System::Void PackageForm::AddGame_Selected(System::Object^ sender, System::EventArgs^ e)
|
|
|
2011 |
{
|
|
|
2012 |
System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
|
|
|
2013 |
|
|
|
2014 |
int done = 0;
|
|
|
2015 |
if (ListFiles->SelectedItems->Count)
|
|
|
2016 |
{
|
|
|
2017 |
for (int i = 0; i < ListFiles->SelectedItems->Count; i++)
|
|
|
2018 |
{
|
224 |
cycrow |
2019 |
int id = _WS(cli::safe_cast<System::String ^>(this->ListFiles->SelectedItems[i]->Tag)).toInt();
|
127 |
cycrow |
2020 |
C_File *file = m_pPackage->GetFileList()->Get(id);
|
|
|
2021 |
if (file) {
|
|
|
2022 |
int iGame = Convert::ToInt32(item->Tag);
|
|
|
2023 |
if (iGame)
|
|
|
2024 |
file->setGame(file->game() | 1 << iGame | 1 << 31);
|
|
|
2025 |
++done;
|
|
|
2026 |
}
|
|
|
2027 |
}
|
|
|
2028 |
}
|
|
|
2029 |
|
|
|
2030 |
if (done) {
|
|
|
2031 |
this->UpdateFileList();
|
|
|
2032 |
this->UpdateChanged();
|
|
|
2033 |
}
|
|
|
2034 |
}
|
|
|
2035 |
System::Void PackageForm::RemoveGame_Selected(System::Object^ sender, System::EventArgs^ e)
|
|
|
2036 |
{
|
|
|
2037 |
System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
|
|
|
2038 |
|
|
|
2039 |
int done = 0;
|
|
|
2040 |
if (ListFiles->SelectedItems->Count)
|
|
|
2041 |
{
|
|
|
2042 |
for (int i = 0; i < ListFiles->SelectedItems->Count; i++)
|
|
|
2043 |
{
|
224 |
cycrow |
2044 |
int id = _WS(cli::safe_cast<System::String ^>(this->ListFiles->SelectedItems[i]->Tag)).toInt();
|
127 |
cycrow |
2045 |
C_File *file = m_pPackage->GetFileList()->Get(id);
|
|
|
2046 |
if (file) {
|
|
|
2047 |
int iGame = Convert::ToInt32(item->Tag);
|
|
|
2048 |
if (iGame)
|
|
|
2049 |
file->setGame(file->game() & ~(1 << iGame));
|
|
|
2050 |
++done;
|
|
|
2051 |
}
|
|
|
2052 |
}
|
|
|
2053 |
}
|
|
|
2054 |
|
|
|
2055 |
if (done) {
|
|
|
2056 |
this->UpdateFileList();
|
|
|
2057 |
this->UpdateChanged();
|
|
|
2058 |
}
|
|
|
2059 |
}
|
|
|
2060 |
}
|