Subversion Repositories spk

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
#pragma once
2
 
3
#include "PackageForm.h"
4
#include "MultiForm.h"
5
#include "Options.h"
6
#include "LoadShip.h"
7
#include "ImportShip.h"
8
#include "CreationWizard.h"
9
#include "LoadText.h"
2 cycrow 10
//TODO: remove this dependacy
11
#include "../../ModMerge/src/Forms/Form1.h"
1 cycrow 12
#include "ModDiff.h"
13
#include "Waiting.h"
14
#include "FileExplorer.h"
15
#include "SelectGame.h"
16
 
17
using namespace System;
18
using namespace System::IO;
19
 
20
namespace Creator {
21
 
22
	enum {SWITCH_NONE, SWITCH_CREATE, SWITCH_EXTRACT, SWITCH_EXTRACTHERE, SWITCH_EXPORT};
23
 
24
	using namespace System;
25
	using namespace System::ComponentModel;
26
	using namespace System::Collections;
27
	using namespace System::Windows::Forms;
28
	using namespace System::Data;
29
	using namespace System::Drawing;
30
 
31
	/// <summary>
32
	/// Summary for Form1
33
	///
34
	/// WARNING: If you change the name of this class, you will need to change the
35
	///          'Resource File Name' property for the managed resource compiler tool
36
	///          associated with all .resx files this class depends on.  Otherwise,
37
	///          the designers will not be able to interact properly with localized
38
	///          resources associated with this form.
39
	/// </summary>
40
	public ref class Form1 : public System::Windows::Forms::Form
41
	{
42
	public:
43
		Form1(array<System::String ^> ^args)
44
		{
45
			InitializeComponent();
46
 
47
			m_bAutoClose = false;
48
			m_pWait = nullptr;
49
			m_bTextLoaded = false;
50
			this->shipToolStripMenuItem->Image = this->imageList1->Images[1];
51
			this->shipToolStripMenuItem1->Image = this->imageList1->Images[1];
52
			this->multiPackageToolStripMenuItem->Image = this->imageList1->Images[this->imageList1->Images->IndexOfKey("multi")];
53
			this->Closed += gcnew System::EventHandler(this, &Form1::CloseEvent);
54
 
55
			textList = gcnew Hashtable();
56
 
57
			this->Text = "Package Creator " + GetVersionString();
58
			m_pLoadedList = new CyStringList;
59
			m_pGameDir = new CLinkList<SGameDir>;
60
 
61
			// default settings
62
			m_settings = new SSettings;
63
			m_settings->bGenerateUpdate = false;
64
 
65
			m_pComponents = NULL;
66
			m_pDummies = NULL;
67
			m_pBodies = NULL;
68
			m_pShields = NULL;
69
			m_pCockpits = new CLinkList<CyStringList>;
70
			m_pLasers = new CLinkList<CyStringList>;
71
			m_pMissiles = new CLinkList<CyStringList>;
72
 
73
			m_iLocX = m_iLocY = -1;
74
			this->LoadData();
75
 
76
			this->toolTip1->SetToolTip(this->button1, "Closes all open windows, will ask about saving any that have been modified when they close");
77
 
78
			m_pPackages = new CPackages;
79
			m_pPackages->Startup(".", CyStringFromSystemString(IO::Path::GetTempPath()), CyStringFromSystemString(Environment::GetFolderPath(Environment::SpecialFolder::Personal )));
80
			m_pPackages->SetLanguage(44);
81
 
82
			this->UpdateDisplay();
83
 
84
			// parse any switches
85
			int switchType = SWITCH_NONE;
86
 
87
			if ( args ) {
88
				ArrayList ^list = gcnew ArrayList();
89
				for ( int i = 0; i < args->Length; i++ ) {
90
					String ^str = args[i];
91
					if ( switchType != SWITCH_NONE ) {
92
						switch(switchType) {
93
							case SWITCH_CREATE:
94
								this->SavePackagerScript(str);
95
								m_bAutoClose = true;
96
								break;
97
							case SWITCH_EXTRACT:
98
								this->ExtractPackage(str, false);
99
								m_bAutoClose = true;
100
								break;
101
							case SWITCH_EXTRACTHERE:
102
								this->ExtractPackage(str, true);
103
								m_bAutoClose = true;
104
								break;
105
							case SWITCH_EXPORT:
106
								this->ExportPackage(str);
107
								m_bAutoClose = true;
108
								break;
109
						}
110
						switchType = SWITCH_NONE;
111
					}
112
					else if ( !String::Compare(str, "--create", true) ) {
113
						switchType = SWITCH_CREATE;			
114
					}
115
					else if ( !String::Compare(str, "--extract", true) ) {
116
						switchType = SWITCH_EXTRACT;
117
					}
118
					else if ( !String::Compare(str, "--extracthere", true) ) {
119
						switchType = SWITCH_EXTRACTHERE;
120
					}
121
					else if ( !String::Compare(str, "--export", true) ) {
122
						switchType = SWITCH_EXPORT;
123
					}
124
					else {
125
						list->Add(args[i]);
126
					}
127
				}
128
 
129
				if ( list->Count ) {
130
					this->OpenFiles(list, true, true);
131
					m_bAutoClose = false;
132
				}
133
			}
134
		}
135
 
136
		int GetHighestGame()
137
		{
138
			int highest = 1;
139
			for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() )
140
			{
141
				int checkgame = gd->sGame.GetToken(" ", 1, 1).ToInt();
142
				if ( checkgame > highest )
143
					highest = checkgame;
144
			}
145
			return highest;
146
		}
147
 
148
		void ModMerge()
149
		{
150
			ModMerge::Form1 ^merge = gcnew ModMerge::Form1();
151
			merge->StartPosition = Windows::Forms::FormStartPosition::CenterParent;
152
			merge->TopMost = true;
153
			if ( !m_pGameDir->empty() )
154
				merge->SetGameDir(-1, SystemStringFromCyString(m_pGameDir->Front()->Data()->sDir));
155
			merge->ShowDialog(this);
156
		}
157
 
158
		void ModDiffDialog()
159
		{
160
			ModDiff ^diff = gcnew ModDiff(m_pGameDir, m_pPackages);
161
			diff->ShowDialog(this);
162
		}
163
 
164
		void OpenArchive()
165
		{
166
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
167
			ofd->Filter = "All Supported Archives|*.zip; *.rar|Zip Archive (*.zip)|*.zip|Rar Archive (*.rar)|*.rar";
168
			ofd->Title = "Select archive file you wish to import from";
169
			ofd->FilterIndex = 1;
170
			ofd->RestoreDirectory = true;
171
			ofd->Multiselect = false;
172
 
173
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
174
			{
175
				m_sConvertFile = ofd->FileName;
176
				m_pWait = gcnew Waiting("Converting Archive");
177
				this->backgroundWorker1->RunWorkerAsync();
178
				m_pWait->ShowDialog(this);
179
			}
180
		}
181
 
182
		CyStringList *FindLasersList(int game)
183
		{
184
			// return the list
185
			if ( game < m_pLasers->size() )
186
			{
187
				if ( !m_pLasers->Get(game)->Empty() )
188
					return m_pLasers->Get(game);
189
			}
190
 
191
			// other wise create the list we need
192
			// first we need to create entries for the ones we are not using
193
			while ( m_pLasers->size() < game )
194
				m_pLasers->push_back(new CyStringList);
195
 
196
			CyStringList *list = new CyStringList;
197
			m_pLasers->push_back(list);
198
 
199
			return list;
200
		}
201
 
202
		CyStringList *GetLasers(int game)
203
		{
204
			CyStringList *list = FindLasersList(game);
205
			if ( !list ) return NULL;
206
 
207
			if ( list->Empty() )
208
			{
209
				for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() )
210
				{
211
					int checkgame = gd->sGame.GetToken(" ", 1, 1).ToInt();
212
					if ( checkgame != game )
213
						continue;
214
					int e = m_pPackages->ExtractGameFile("types\\TLaser.pck", m_pPackages->GetTempDirectory() + "/TLaser.txt", gd->sDir);
215
					if ( e )
216
					{
217
						CFileIO File((e == -1) ? "TLaser.txt" : m_pPackages->GetTempDirectory() + "/TLaser.txt");
218
						CyStringList *lines = File.ReadLinesStr();
219
						if ( lines )
220
						{
221
							int itemsRemaining = -1;
222
							for ( SStringList *str = lines->Head(); str; str = str->next )
223
							{
224
								str->str.RemoveChar('\r');
225
								str->str.RemoveChar(9);
226
								str->str.RemoveFirstSpace();
227
 
228
								if ( str->str.Empty() )
229
									continue;
230
								if ( str->str[0] == '/' )
231
									continue;
232
 
233
								if ( itemsRemaining == -1 )
234
									itemsRemaining = str->str.GetToken(";", 2, 2).ToInt();
235
								else
236
								{
237
									list->PushBack(str->str, CyStringFromSystemString(this->FindText(game, TEXTPAGE_OBJECTS, str->str.GetToken(";", 7, 7).ToInt())));
238
									--itemsRemaining;
239
								}
240
							}
241
 
242
							delete lines;
243
							return list;
244
						}
245
					}
246
				}
247
			}
248
 
249
			return list;
250
		}
251
 
252
		CyStringList *GetMissiles(int game)
253
		{
254
			// return the list
255
			if ( game < m_pMissiles->size() )
256
			{
257
				if ( !m_pMissiles->Get(game)->Empty() )
258
					return m_pMissiles->Get(game);
259
			}
260
 
261
			// other wise create the list we need
262
			// first we need to create entries for the ones we are not using
263
			while ( m_pMissiles->size() < game )
264
				m_pMissiles->push_back(new CyStringList);
265
 
266
			CyStringList *list = new CyStringList;
267
			m_pMissiles->push_back(list);
268
 
269
			for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() )
270
			{
271
				int checkgame = gd->sGame.GetToken(" ", 1, 1).ToInt();
272
				if ( checkgame != game )
273
					continue;
274
				int e = m_pPackages->ExtractGameFile("types\\TMissiles.pck", m_pPackages->GetTempDirectory() + "/TMissiles.txt", gd->sDir);
275
				if ( e )
276
				{
277
					CFileIO File((e == -1) ? "TMissiles.txt" : m_pPackages->GetTempDirectory() + "/TMissiles.txt");
278
					CyStringList *lines = File.ReadLinesStr();
279
					if ( lines )
280
					{
281
						int itemsRemaining = -1;
282
						for ( SStringList *str = lines->Head(); str; str = str->next )
283
						{
284
							str->str.RemoveChar('\r');
285
							str->str.RemoveChar(9);
286
							str->str.RemoveFirstSpace();
287
 
288
							if ( str->str.Empty() )
289
								continue;
290
							if ( str->str[0] == '/' )
291
								continue;
292
 
293
							if ( itemsRemaining == -1 )
294
								itemsRemaining = str->str.GetToken(";", 2, 2).ToInt();
295
							else
296
							{
297
								list->PushBack(str->str, CyStringFromSystemString(this->FindText(game, TEXTPAGE_OBJECTS, str->str.GetToken(";", 7, 7).ToInt())));
298
								--itemsRemaining;
299
							}
300
						}
301
 
302
						delete lines;
303
						return list;
304
					}
305
				}
306
			}
307
 
308
			return list;
309
		}
310
 
311
		CyStringList *GetShields()
312
		{
313
			if ( !m_pShields )
314
			{
315
				bool found = false;
316
				for ( int game = 2; game >= 0; game-- )
317
				{
318
					for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() )
319
					{
320
						int checkgame = gd->sGame.GetToken(" ", 1, 1).ToInt();
321
						if ( checkgame != game )
322
							continue;
323
						if ( m_pPackages->ExtractGameFile("types\\TShields.pck", m_pPackages->GetTempDirectory() + "/TShields.txt", gd->sDir) )
324
						{
325
							if ( !m_pShields )
326
								m_pShields = new CyStringList;
327
 
328
							CFileIO File(m_pPackages->GetTempDirectory() + "/TShields.txt");
329
							CyStringList *lines = File.ReadLinesStr();
330
							if ( lines )
331
							{
332
								int itemsRemaining = -1;
333
								for ( SStringList *str = lines->Head(); str; str = str->next )
334
								{
335
									str->str.RemoveChar('\r');
336
									str->str.RemoveChar(9);
337
									str->str.RemoveFirstSpace();
338
 
339
									if ( str->str.Empty() )
340
										continue;
341
									if ( str->str[0] == '/' )
342
										continue;
343
 
344
									if ( itemsRemaining == -1 )
345
										itemsRemaining = str->str.GetToken(";", 2, 2).ToInt();
346
									else
347
									{
348
										m_pShields->PushBack(str->str, CyStringFromSystemString(this->FindText(game, TEXTPAGE_OBJECTS, str->str.GetToken(";", 7, 7).ToInt())));
349
										--itemsRemaining;
350
									}
351
								}
352
 
353
								delete lines;
354
								found = true;
355
								break;
356
							}
357
						}
358
					}
359
 
360
					if ( found )
361
						break;
362
				}
363
			}
364
 
365
			return m_pShields;
366
		}
367
 
368
		CyStringList *GetCockpits(int game)
369
		{
370
			// return the list
371
			if ( game < m_pCockpits->size() )
372
			{
373
				if ( !m_pCockpits->Get(game)->Empty() )
374
					return m_pCockpits->Get(game);
375
			}
376
 
377
			// other wise create the list we need
378
			// first we need to create entries for the ones we are not using
379
			while ( m_pCockpits->size() < game )
380
				m_pCockpits->push_back(new CyStringList);
381
 
382
			CyStringList *list = new CyStringList;
383
			m_pCockpits->push_back(list);
384
 
385
			for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() )
386
			{
387
				int checkgame = gd->sGame.GetToken(" ", 1, 1).ToInt();
388
				if ( checkgame != game )
389
					continue;
390
				if ( m_pPackages->ExtractGameFile("types\\TCockpits.pck", m_pPackages->GetTempDirectory() + "/TCockpits.txt", gd->sDir) )
391
				{
392
					CFileIO File(m_pPackages->GetTempDirectory() + "/TCockpits.txt");
393
					CyStringList *lines = File.ReadLinesStr();
394
					if ( lines )
395
					{
396
						int itemsRemaining = -1;
397
						for ( SStringList *str = lines->Head(); str; str = str->next )
398
						{
399
							str->str.RemoveChar('\r');
400
							str->str.RemoveChar(9);
401
							str->str.RemoveFirstSpace();
402
 
403
							if ( str->str.Empty() )
404
								continue;
405
							if ( str->str[0] == '/' )
406
								continue;
407
 
408
							if ( itemsRemaining == -1 )
409
								itemsRemaining = str->str.GetToken(";", 2, 2).ToInt();
410
							else
411
							{
412
								list->PushBack(str->str, str->str.GetToken(";", 19, 19));
413
								--itemsRemaining;
414
							}
415
						}
416
 
417
						delete lines;
418
						File.Remove();
419
						return list;
420
					}
421
					File.Remove();
422
				}
423
			}
424
			return list;
425
		}
426
 
427
		CyStringList *GetComponentSections()
428
		{
429
			// need to load data
430
			if ( !m_pComponents )
431
			{
432
				bool found = false;
433
				for ( int game = 2; game >= 0; game-- )
434
				{
435
					for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() )
436
					{
437
						int checkgame = gd->sGame.GetToken(" ", 1, 1).ToInt();
438
						if ( checkgame != game )
439
							continue;
440
						if ( m_pPackages->ExtractGameFile("types\\Components.pck", m_pPackages->GetTempDirectory() + "/components.txt", gd->sDir) )
441
						{
442
							if ( !m_pComponents )
443
								m_pComponents = new CyStringList;
444
							CFileIO File(m_pPackages->GetTempDirectory() + "/components.txt");
445
							CyStringList *lines = File.ReadLinesStr();
446
							if ( lines )
447
							{
448
								int sectionRemaining = 0;
449
								int itemsRemaining = 0;
450
								for ( SStringList *str = lines->Head(); str; str = str->next )
451
								{
452
									str->str.RemoveChar('\r');
453
									str->str.RemoveChar(9);
454
									str->str.RemoveFirstSpace();
455
 
456
									if ( str->str.Empty() )
457
										continue;
458
									if ( str->str[0] == '/' )
459
										continue;
460
 
461
									if ( itemsRemaining )
462
										--itemsRemaining;
463
									else if ( !sectionRemaining )
464
									{
465
										sectionRemaining = str->str.GetToken(";", 2, 2).ToInt();
466
										CyString sec = str->str.GetToken(";", 1, 1);
467
										if ( !sec.Empty() )
468
											m_pComponents->PushBack(sec);
469
									}
470
									else if ( !itemsRemaining )
471
									{
472
										itemsRemaining = str->str.GetToken(";", 2, 2).ToInt();
473
										--sectionRemaining;
474
									}
475
								}
476
 
477
								delete lines;
478
								found = true;
479
								break;
480
							}
481
						}
482
					}
483
 
484
					if ( found )
485
						break;
486
				}
487
 
488
				// still empty
489
				if ( !m_pComponents )
490
					m_pComponents = new CyStringList;
491
				if ( m_pComponents->Empty() )
492
				{
493
					m_pComponents->PushBack("SCTYPE_LASER");
494
					m_pComponents->PushBack("SCTYPE_COCKPIT");
495
					m_pComponents->PushBack("SCTYPE_DOCKING");
496
				}
497
			}
498
			return m_pComponents;
499
		}
500
 
501
		CyStringList *GetDummySections()
502
		{
503
			if ( !m_pDummies )
504
			{
505
				bool found = false;
506
				for ( int game = 2; game >= 0; game-- )
507
				{
508
					for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() )
509
					{
510
						int checkgame = gd->sGame.GetToken(" ", 1, 1).ToInt();
511
						if ( checkgame != game )
512
							continue;
513
						if ( m_pPackages->ExtractGameFile("types\\Dummies.pck", m_pPackages->GetTempDirectory() + "/Dummies.txt", gd->sDir) )
514
						{
515
							if ( !m_pDummies )
516
								m_pDummies = new CyStringList;
517
							CFileIO File(m_pPackages->GetTempDirectory() + "/Dummies.txt");
518
							CyStringList *lines = File.ReadLinesStr();
519
							if ( lines )
520
							{
521
								int sectionRemaining = 0;
522
								for ( SStringList *str = lines->Head(); str; str = str->next )
523
								{
524
									str->str.RemoveChar('\r');
525
									str->str.RemoveChar(9);
526
									str->str.RemoveFirstSpace();
527
 
528
									if ( str->str.Empty() )
529
										continue;
530
									if ( str->str[0] == '/' )
531
										continue;
532
 
533
									if ( !sectionRemaining )
534
									{
535
										sectionRemaining = str->str.GetToken(";", 2, 2).ToInt();
536
										CyString sec = str->str.GetToken(";", 1, 1);
537
										if ( !sec.Empty() )
538
											m_pDummies->PushBack(sec);
539
									}
540
									else
541
										--sectionRemaining;
542
								}
543
 
544
								delete lines;
545
								found = true;
546
								break;
547
							}
548
						}
549
					}
550
 
551
					if ( found )
552
						break;
553
				}
554
				// still empty
555
				if ( !m_pDummies )
556
					m_pDummies = new CyStringList;
557
				if ( m_pDummies->Empty() )
558
				{
559
					m_pDummies->PushBack("SDTYPE_ANIMATED");
560
					m_pDummies->PushBack("SDTYPE_DOCK");
561
					m_pDummies->PushBack("SDTYPE_DOORWAY");
562
					m_pDummies->PushBack("SDTYPE_GUN");
563
					m_pDummies->PushBack("SDTYPE_CONNTECTION");
564
				}
565
			}
566
			return m_pDummies;
567
		}
568
 
569
		CyStringList *GetBodiesSections()
570
		{
571
			if ( !m_pBodies )
572
			{
573
				bool found = false;
574
				for ( int game = 2; game >= 0; game-- )
575
				{
576
					for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() )
577
					{
578
						int checkgame = gd->sGame.GetToken(" ", 1, 1).ToInt();
579
						if ( checkgame != game )
580
							continue;
581
						if ( m_pPackages->ExtractGameFile("types\\Bodies.pck", m_pPackages->GetTempDirectory() + "/Bodies.txt", gd->sDir) )
582
						{
583
							if ( !m_pBodies )
584
								m_pBodies = new CyStringList;
585
							CFileIO File(m_pPackages->GetTempDirectory() + "/Bodies.txt");
586
							CyStringList *lines = File.ReadLinesStr();
587
							if ( lines )
588
							{
589
								int sectionRemaining = 0;
590
								for ( SStringList *str = lines->Head(); str; str = str->next )
591
								{
592
									str->str.RemoveChar('\r');
593
									str->str.RemoveChar(9);
594
									str->str.RemoveFirstSpace();
595
 
596
									if ( str->str.Empty() )
597
										continue;
598
									if ( str->str[0] == '/' )
599
										continue;
600
 
601
									if ( !sectionRemaining )
602
									{
603
										sectionRemaining = str->str.GetToken(";", 2, 2).ToInt();
604
										CyString sec = str->str.GetToken(";", 1, 1);
605
										if ( !sec.Empty() )
606
											m_pBodies->PushBack(sec);
607
									}
608
									else
609
									{
610
										sectionRemaining -= (str->str.NumToken(";") - 1);
611
									}
612
								}
613
 
614
								delete lines;
615
								found = true;
616
								break;
617
							}
618
						}
619
					}
620
 
621
					if ( found )
622
						break;
623
				}
624
				// still empty
625
				if ( !m_pBodies )
626
					m_pBodies = new CyStringList;
627
				if ( m_pBodies->Empty() )
628
				{
629
					m_pBodies->PushBack("SBTYPE_2D");
630
					m_pBodies->PushBack("SBTYPE_FACECAMERA");
631
					m_pBodies->PushBack("SBTYPE_2D2");
632
					m_pBodies->PushBack("SBTYPE_2DY");
633
					m_pBodies->PushBack("SBTYPE_LOGO");
634
					m_pBodies->PushBack("SBTYPE_FC");
635
					m_pBodies->PushBack("SBTYPE_TURRET");
636
					m_pBodies->PushBack("SBTYPE_JET");
637
					m_pBodies->PushBack("SBTYPE_RADAR");
638
					m_pBodies->PushBack("SBTYPE_CONTAINER");
639
					m_pBodies->PushBack("SBTYPE_DISPLAY");
640
					m_pBodies->PushBack("SBTYPE_DOCKPOINT");
641
					m_pBodies->PushBack("SBTYPE_SMALLJET");
642
				}
643
			}
644
			return m_pBodies;
645
		}
646
 
647
		String ^ParseText(int game, String ^text)
648
		{
649
			String ^t = text;
650
 
651
			bool found = true;
652
			int pos = 0;
653
			while (found)
654
			{
655
				pos = t->IndexOf('{', pos);
656
				found = false;
657
				if ( pos > -1 )
658
				{
659
					int page = -1;
660
					int id = -1;
661
 
662
					int commaPos = t->IndexOf(',', pos);
663
					if ( commaPos > -1 )
664
					{
665
						page = Convert::ToInt32(t->Substring(pos + 1, commaPos - (pos + 1)));
666
						int endPos = t->IndexOf('}', commaPos);
667
						if ( endPos > -1 )
668
						{
669
							id = Convert::ToInt32(t->Substring(commaPos + 1, endPos - (commaPos + 1)));
670
							found = true;
671
							t = t->Replace(t->Substring(pos, endPos - pos + 1 ), this->FindText(game, page, id));
672
						}
673
					}
674
				}
675
			}
676
			return t;
677
		}
678
 
679
		String ^FindText(int game, int page, int id)
680
		{
681
			this->LoadText(false, false);
682
			String ^text;
683
			if ( game == -1 )
684
			{
685
				for ( int game = (GAME_MAX - 1); game >= 0; game-- )
686
				{
687
					String ^key = Convert::ToString(game) + "," + Convert::ToString(page) + "," + Convert::ToString(id);
688
					if ( this->textList->ContainsKey(key) )
689
					{
690
						text = ParseText(game, Convert::ToString(this->textList[key]));
691
						break;
692
					}
693
				}
694
			}
695
			else
696
			{
697
				String ^key = Convert::ToString(game) + "," + Convert::ToString(page) + "," + Convert::ToString(id);
698
				if ( this->textList->ContainsKey(key) )
699
					text = ParseText(game, Convert::ToString(this->textList[key]));
700
			}
701
 
702
			return text;
703
		}
704
 
705
		void UpdateStatus()
706
		{
707
			bool e = (this->tabControl1->HasChildren) ? true : false;
708
 
709
			BaseForm ^active = this->GetActiveChild();
710
			if ( active && active->GetFormType() == FORMTYPE_SINGLE )
711
			{
712
				CBaseFile *activePackage = ((PackageForm ^)active)->GetPackage();
713
				if ( !activePackage )
714
					e = false;
715
				else
716
					this->StatusFiles->Text = "Files: " + activePackage->GetFileList()->size() + " (" + SystemStringFromCyString(activePackage->GetFullFileSizeString()) + ")";
717
			}
718
			else if ( active && active->GetFormType() == FORMTYPE_MULTI )
719
			{
720
				CMultiSpkFile *activePackage = ((MultiForm ^)active)->GetPackage();
721
				if ( !activePackage )
722
					e = false;
723
				else
724
					this->StatusFiles->Text = "Files: " + activePackage->GetAvailableFiles() + " (" + SystemStringFromCyString(SPK::GetSizeString(activePackage->GetFileSize())) + ")";
725
			}
726
			else
727
				e = false;
728
 
729
			if ( !e  )
730
				this->StatusFiles->Text = "";
731
		}
732
 
733
		void UpdateDisplay()
734
		{
735
			bool e = (this->tabControl1->HasChildren) ? true : false;
736
 
737
			BaseForm ^active = this->GetActiveChild();
738
			if ( !active )
739
				e = false;
740
			else if ( active->GetFormType() != FORMTYPE_SINGLE && active->GetFormType() != FORMTYPE_MULTI)
741
				e = false;
742
 
743
			this->saveAsToolStripMenuItem->Enabled = e;
744
			this->saveToolStripMenuItem->Enabled = e;
745
			this->tabControl1->Visible = e;
746
 
747
			if ( !this->PanelTab->Visible && e )
748
			{
749
				this->PanelTab->Visible = e;
750
				this->toolStrip1->SendToBack();
751
				this->menuStrip1->SendToBack();
752
			}
753
			else if ( !e )
754
				this->PanelTab->Visible = e;
755
 
756
			this->UpdateStatus();
757
			this->UpdateDropDownOpen();
758
		}
759
 
760
		void OpenFileExplorer()
761
		{
762
			FileExplorer ^file = gcnew FileExplorer(this, m_pPackages);
763
			file->Show(this);
764
		}
765
 
766
		void OpenFile(String ^filename)
767
		{
768
			ArrayList ^a = gcnew ArrayList();
769
			a->Add(filename);
770
 
771
			this->OpenFiles(a, false, true);
772
		}
773
 
774
	protected:
775
		/// <summary>
776
		/// Clean up any resources being used.
777
		/// </summary>
778
		~Form1()
779
		{
780
			if (components)
781
			{
782
				delete components;
783
			}
784
			delete m_pLoadedList;
785
			delete m_pPackages;
786
			m_pGameDir->MemoryClear();
787
			delete m_pGameDir;
788
 
789
			for ( CyStringList *list = m_pLasers->First(); list; list = m_pLasers->Next() )
790
				delete list;
791
			for ( CyStringList *list = m_pMissiles->First(); list; list = m_pMissiles->Next() )
792
				delete list;
793
			for ( CyStringList *list = m_pCockpits->First(); list; list = m_pCockpits->Next() )
794
				delete list;
795
			delete m_pLasers;
796
			delete m_pMissiles;
797
			delete m_pCockpits;
798
			if ( m_pShields )
799
				delete m_pShields;
800
			if ( m_pComponents )
801
				delete m_pComponents;
802
			if ( m_pDummies )
803
				delete m_pDummies;
804
			if ( m_pBodies )
805
				delete m_pBodies;
806
			delete m_settings;
807
		}
808
 
809
	protected: 
810
		bool			 m_bAutoClose;
811
		int				 m_iLocX;
812
		int				 m_iLocY;
813
		CLinkList<CyStringList> *m_pLasers;
814
		CLinkList<CyStringList> *m_pMissiles;
815
		CLinkList<CyStringList> *m_pCockpits;
816
		CyStringList	*m_pShields;
817
		CyStringList	*m_pLoadedList;
818
		CPackages *m_pPackages;
819
		CLinkList<SGameDir>	*m_pGameDir;
820
		CyStringList	*m_pComponents;
821
		CyStringList	*m_pDummies;
822
		CyStringList	*m_pBodies;
823
		SSettings		*m_settings;
824
		bool			 m_bTextLoaded;
825
		String			^m_sConvertFile;
826
		Waiting			^m_pWait;
827
		CBaseFile		*m_pConverted;
828
 
829
		System::Collections::Hashtable ^textList;
830
 
831
	private: System::Windows::Forms::MenuStrip^  menuStrip1;
832
	private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;
833
	private: System::Windows::Forms::ToolStripMenuItem^  newToolStripMenuItem;
834
	private: System::Windows::Forms::ToolStripMenuItem^  packageToolStripMenuItem;
835
	private: System::Windows::Forms::ToolStripMenuItem^  shipToolStripMenuItem;
836
	private: System::Windows::Forms::ToolStripMenuItem^  windowsToolStripMenuItem;
837
	private: System::Windows::Forms::ToolStripMenuItem^  layoutToolStripMenuItem;
838
	private: System::Windows::Forms::ToolStripMenuItem^  cascadeToolStripMenuItem;
839
	private: System::Windows::Forms::ToolStripMenuItem^  horizontalToolStripMenuItem;
840
	private: System::Windows::Forms::ToolStripMenuItem^  verticalToolStripMenuItem;
841
	private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator1;
842
	private: System::Windows::Forms::ToolStripMenuItem^  openToolStripMenuItem;
843
	private: System::Windows::Forms::ToolStripMenuItem^  saveToolStripMenuItem;
844
	private: System::Windows::Forms::ToolStripMenuItem^  saveAsToolStripMenuItem;
845
	private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator2;
846
	private: System::Windows::Forms::Panel^  PanelTab;
847
	private: System::Windows::Forms::TabControl^  tabControl1;
848
	private: System::Windows::Forms::Button^  button1;
849
	private: System::Windows::Forms::ToolStrip^  toolStrip1;
850
	private: System::Windows::Forms::ToolStripSplitButton^  toolStripSplitButton1;
851
 
852
	private: System::Windows::Forms::ImageList^  imageList1;
853
	private: System::Windows::Forms::ToolStripDropDownButton^  toolStripButton1;
854
	private: System::Windows::Forms::ToolStripMenuItem^  packageToolStripMenuItem1;
855
	private: System::Windows::Forms::ToolStripMenuItem^  shipToolStripMenuItem1;
856
 
857
 
858
	private: System::Windows::Forms::Timer^  timer1;
859
	private: System::Windows::Forms::StatusStrip^  statusStrip1;
860
	private: System::Windows::Forms::ToolStripStatusLabel^  StatusFiles;
861
private: System::Windows::Forms::ToolStripMenuItem^  settingsToolStripMenuItem;
862
private: System::Windows::Forms::ToolStripMenuItem^  configToolStripMenuItem;
863
private: System::Windows::Forms::ImageList^  imageListGames;
864
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator3;
865
private: System::Windows::Forms::ToolStripButton^  toolStripButton2;
866
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator5;
867
private: System::Windows::Forms::ToolStripMenuItem^  fromPackagerScriptToolStripMenuItem1;
868
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator4;
869
private: System::Windows::Forms::ToolStripMenuItem^  fromPackagerScriptToolStripMenuItem;
870
private: System::Windows::Forms::ToolStripMenuItem^  importShipFromModToolStripMenuItem1;
871
private: System::Windows::Forms::ToolStripMenuItem^  importShipFromModToolStripMenuItem;
872
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator6;
873
private: System::Windows::Forms::ToolStripMenuItem^  packageCreationWizardToolStripMenuItem;
874
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator7;
875
private: System::Windows::Forms::ToolStripMenuItem^  packageCreationWizardToolStripMenuItem1;
876
private: System::Windows::Forms::ToolTip^  toolTip1;
877
private: System::Windows::Forms::ImageList^  imageListSmall;
878
private: System::Windows::Forms::ImageList^  imageListLarge;
879
private: System::Windows::Forms::ImageList^  imageListFiles;
880
private: System::Windows::Forms::ToolStripMenuItem^  multiPackageToolStripMenuItem;
881
private: System::Windows::Forms::ToolStripMenuItem^  toolsToolStripMenuItem;
882
private: System::Windows::Forms::ToolStripMenuItem^  modMergeToolStripMenuItem;
883
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator8;
884
private: System::Windows::Forms::ToolStripDropDownButton^  toolStripDropDownButton1;
885
private: System::Windows::Forms::ToolStripMenuItem^  modMergeToolStripMenuItem1;
886
private: System::Windows::Forms::ToolStripMenuItem^  modDiffToolStripMenuItem;
887
private: System::Windows::Forms::ToolStripMenuItem^  modDiffToolStripMenuItem1;
888
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator10;
889
private: System::Windows::Forms::ToolStripMenuItem^  generatePackageWebListToolStripMenuItem1;
890
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator9;
891
private: System::Windows::Forms::ToolStripMenuItem^  generatePackageWebListToolStripMenuItem;
892
private: System::Windows::Forms::ToolStripMenuItem^  fromArchiveToolStripMenuItem;
893
private: System::ComponentModel::BackgroundWorker^  backgroundWorker1;
894
private: System::Windows::Forms::ToolStripMenuItem^  generatePackageUpdatesToolStripMenuItem;
895
private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator11;
896
private: System::Windows::Forms::ToolStripMenuItem^  fileExplorerToolStripMenuItem;
897
 
898
	private: System::Windows::Forms::ToolStripMenuItem^  exitToolStripMenuItem;
899
 
900
 
901
	private:
902
		BaseForm ^GetActiveChild()
903
		{
904
			 cli::array<System::Windows::Forms::Form ^> ^children = this->MdiChildren;
905
			 for ( int i = 0; i < children->Length; i++ )
906
			 {
907
				 BaseForm ^childForm = (BaseForm ^)children[i];
908
				 if ( !childForm->TabPage() )
909
					 continue;
910
				 if ( childForm->TabPage()->Equals(tabControl1->SelectedTab) )
911
					 return childForm;
912
			 }
913
 
914
			 return nullptr;
915
		}
916
 
917
 
918
		void ImportShip()
919
		{
920
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
921
			ofd->Filter = "X Catalog Files (*.cat)|*.cat";
922
			ofd->Title = "Select the mod file to import a ship from";
923
			ofd->FilterIndex = 1;
924
			ofd->RestoreDirectory = true;
925
			ofd->Multiselect = false;
926
 
927
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
928
			{
929
				this->UseWaitCursor = true;
930
				// if its a cat file, lets load the text
931
				Hashtable ^catText = gcnew Hashtable();
932
				CyStringList readText;
933
				if ( m_pPackages->ReadTextPage(CyStringFromSystemString(ofd->FileName), &readText, false, 17) )
934
				{
935
					for ( SStringList *str = readText.Head(); str; str = str->next )
936
					{
937
						String ^key = SystemStringFromCyString(str->str);
938
						if ( catText->ContainsKey(key) )
939
							catText[key] = SystemStringFromCyString(str->data);
940
						else
941
							catText->Add(key, SystemStringFromCyString(str->data));
942
					}
943
				}
944
 
945
				CyStringList list;
946
				if ( m_pPackages->LoadShipData(CyStringFromSystemString(ofd->FileName), &list) )
947
				{
948
					LoadShip ^ls = gcnew LoadShip();
949
					for ( SStringList *str = list.Head(); str; str = str->next )
950
					{
951
						int tId = str->data.GetToken(";", 7, 7).ToInt();
952
						String ^name;
953
						if ( catText->ContainsKey(Convert::ToString(tId)) )
954
							name = Convert::ToString(catText[Convert::ToString(tId)]);
955
						else
956
							name = this->FindText(-1, 17, tId);
957
						String ^text = this->FindText(-1, 1266, str->data.GetToken(";", 46, 46).ToInt()) + " " + name;
958
						int variation = str->data.GetToken(";", 51, 51).ToInt();
959
						if ( variation )
960
							text = text + " " + this->FindText(-1, 17, 10000 + variation);
961
						ls->AddShip(SystemStringFromCyString(str->str), text);
962
					}
963
 
964
					if ( ls->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
965
					{
966
						SStringList *str = list.FindString(CyStringFromSystemString(ls->GetData()));
967
						if ( str )
968
						{
31 cycrow 969
							Creator::ImportShip ^import = gcnew Creator::ImportShip(m_pPackages, ofd->FileName, ls->GetData(), nullptr);
1 cycrow 970
							import->ShowDialog(this);
971
							CXspFile *newShip = (import->Error()) ? NULL : import->GetShip();
31 cycrow 972
							if ( !newShip ) {
973
								if ( MessageBox::Show(this, "There was a problem when trying to import the ship\n" + ofd->FileName + " (" + ls->GetData() + ")\n\nError: " + import->getErrorString() + "\n\nWould you like to read files from another mod as well?", "Error Importing Ship", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes ) {
974
									// load in another file
975
									System::String ^sFilename = ofd->FileName;
976
									if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK ) {
977
										Creator::ImportShip ^import = gcnew Creator::ImportShip(m_pPackages, sFilename, ls->GetData(), ofd->FileName);
978
										import->ShowDialog(this);
979
										newShip = (import->Error()) ? NULL : import->GetShip();
980
										if ( !newShip ) {
981
											MessageBox::Show(this, "There was a problem when trying to import the ship\n" + ofd->FileName + " (" + ls->GetData() + ")\n\nError: " + import->getErrorString(), "Error Importing Ship", MessageBoxButtons::OK, MessageBoxIcon::Error);
982
										}
983
									}
984
								}
985
 
986
							}
987
							if ( newShip ) {
1 cycrow 988
								PackageForm ^childForm = this->OpenPackage(true, newShip, "", "Imported Ship");
989
								childForm->Text = "Imported Ship";
990
								newShip->SetChanged(true);
991
								childForm->UpdateChanged();
992
							}
993
						}
994
					}
995
				}
996
				else
997
					MessageBox::Show(this, "Unable to load ship data from mod file\n" + ofd->FileName, "Error Importing", MessageBoxButtons::OK, MessageBoxIcon::Error);
998
				this->UseWaitCursor = false;
999
			}
1000
		}
1001
 
1002
		void OpenDirectory(System::String ^dir)
1003
		{
1004
			if ( !System::IO::Directory::Exists(dir) )
1005
			{
1006
				MessageBox::Show(this, "Unable to open packages from directory\nDirectory not found\n\n" + dir, "Load Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
1007
				return;
1008
			}
1009
 
1010
			this->OpenFiles(System::IO::Directory::GetFiles(dir, "*.spk"), false, false);
1011
			this->OpenFiles(System::IO::Directory::GetFiles(dir, "*.xsp"), false, false);
1012
		}
1013
 
1014
		void OpenFiles(cli::array<System::String ^> ^list, bool checkExtension, bool display)
1015
		{
1016
			if ( !list )
1017
				return;
1018
 
1019
			for ( int i = 0; i < list->Length; i++ )
1020
				this->Open(list[i], display, checkExtension);
1021
 
1022
			cli::array<System::Windows::Forms::Form ^> ^children = this->MdiChildren;
1023
			for ( int i = 0; i < children->Length; i++ )
1024
			{
1025
				BaseForm ^childForm = (BaseForm ^)children[i];
1026
				if ( !childForm->TabPage()->Visible )
1027
				{
1028
					childForm->Show();
1029
					childForm->TabPage()->Show();
1030
				}
1031
			}
1032
		}
1033
 
1034
		void OpenOptionsMenu()
1035
		{
1036
			 Options ^opt = gcnew Options(this->imageListGames, m_pGameDir, m_pPackages, m_settings);
1037
			 if ( opt->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
1038
			 {
1039
				 m_settings->bGenerateUpdate = opt->GetGenerateUpdate();
1040
			 }
1041
 
1042
			 if ( opt->LoadText() )
1043
				 this->LoadText(false, true);
1044
		}
1045
 
1046
		void OpenFiles(ArrayList ^list, bool checkExtension, bool display)
1047
		{
1048
			if ( !list )
1049
				return;
1050
 
1051
			for ( int i = 0; i < list->Count; i++ )
1052
				this->Open(cli::safe_cast<String ^>(list[i]), display, checkExtension);
1053
 
1054
			cli::array<System::Windows::Forms::Form ^> ^children = this->MdiChildren;
1055
			for ( int i = 0; i < children->Length; i++ )
1056
			{
1057
				BaseForm ^childForm = (BaseForm ^)children[i];
1058
				if ( !childForm->TabPage()->Visible )
1059
				{
1060
					childForm->Show();
1061
					childForm->TabPage()->Show();
1062
				}
1063
			}
1064
		}
1065
 
1066
		void Open()
1067
		{
1068
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
1069
			ofd->Filter = "All (*.spk *.xsp)|*.spk;*.xsp|Package Files (*.spk)|*.spk|Ship Files (*.xsp)|*.xsp";
1070
			ofd->Title = "Select the package/ship file to open";
1071
			ofd->FilterIndex = 1;
1072
			ofd->RestoreDirectory = true;
1073
			ofd->Multiselect = true;
1074
 
1075
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
1076
				this->OpenFiles(ofd->FileNames, false, true);
1077
		}
1078
 
1079
		void LoadFiles(String ^loadFrom)
1080
		{
1081
			if ( System::IO::File::Exists(loadFrom) )
1082
			{
1083
				System::String ^lines = System::IO::File::ReadAllText(loadFrom);
1084
				try { System::IO::File::Delete(loadFrom); }
1085
				catch (System::IO::IOException ^) {}
1086
				catch (System::Exception ^) {}
1087
 
1088
				if ( lines )
1089
				{
1090
					CyString strLines = CyStringFromSystemString(lines);
1091
					int num;
1092
					CyString *aLines = strLines.SplitToken("\n", &num);
1093
					if ( num && aLines )
1094
					{
1095
						ArrayList ^list = gcnew ArrayList();
1096
						for ( int i = 0; i < num; i++ )
1097
						{
1098
							CyString l = aLines[i];
1099
							l = l.Remove("\r");
1100
							CyString first = l.GetToken(":", 1, 1);
1101
							CyString rest = l.GetToken(":", 2);
1102
							rest.RemoveFirstSpace();
1103
 
1104
							if ( first.Compare("File") )
1105
								list->Add(SystemStringFromCyString(rest));
1106
						}
1107
 
1108
						CLEANSPLIT(aLines, num)
1109
 
1110
						this->OpenFiles(list, true, true);
1111
					}
1112
 
1113
				}
1114
			}			
1115
		}
1116
 
1117
		void ExportPackage(String ^file)
1118
		{
1119
			CyString sFile = CyStringFromSystemString(file);
1120
			int error = 0;
1121
 
1122
			CBaseFile *p = m_pPackages->OpenPackage(sFile, &error, 0, SPKREAD_NODATA);
1123
			if ( !p ) {
1124
				MessageBox::Show(this, "Error: Unable to open package file\n" + file, "Error Opening", MessageBoxButtons::OK, MessageBoxIcon::Error);
1125
			}
1126
			else {
1127
				String ^to = IO::FileInfo(file).DirectoryName;
1128
				int game = 0;
1129
				if ( p->IsMultipleGamesInPackage() ) {
1130
					SelectGame ^selGame = gcnew SelectGame("Select game to extract package:\n" + file, m_pPackages);
1131
					if ( selGame->ShowDialog(this) == Windows::Forms::DialogResult::OK ) {
1132
						game = selGame->GetGame() + 1;
1133
					}
1134
					else
1135
						to = nullptr;
1136
				}
1137
				else if ( p->IsAnyGameInPackage() ) {
1138
					game = p->FindFirstGameInPackage();
1139
				}
1140
 
1141
				if ( to && to->Length ) {
1142
					CyString exportFilename = CFileIO(sFile).ChangeFileExtension("zip");
1143
					if ( game ) {
1144
						exportFilename = CFileIO(exportFilename).GetDir() + "/" + CFileIO(exportFilename).GetBaseName() + "_" + CBaseFile::ConvertGameToString(game) + ".zip";
1145
					}
1146
					if ( p->SaveToArchive(exportFilename, game) ) {
1147
						String ^message = "Export: " + file + "\nTo: " + SystemStringFromCyString(CFileIO(exportFilename).GetFilename());
1148
						if ( game ) {
1149
							message += "\nGame: " + SystemStringFromCyString(m_pPackages->GetGameExe()->GetGame(game - 1)->sName);
1150
						}
1151
						MessageBox::Show(this, message, "Exported Package", MessageBoxButtons::OK, MessageBoxIcon::Information);
1152
					}
1153
					else {
1154
						MessageBox::Show(this, "Error: Unable to export to:\n" + SystemStringFromCyString(exportFilename), "Error Export", MessageBoxButtons::OK, MessageBoxIcon::Error);
1155
					}
1156
				}
1157
			}
1158
		}
1159
 
1160
		void ExtractPackage(String ^file, bool here)
1161
		{
1162
			CyString sFile = CyStringFromSystemString(file);
1163
			int error = 0;
1164
 
1165
			CBaseFile *p = m_pPackages->OpenPackage(sFile, &error, 0, SPKREAD_NODATA);
1166
			if ( !p ) {
1167
				MessageBox::Show(this, "Error: Unable to open package file\n" + file, "Error Opening", MessageBoxButtons::OK, MessageBoxIcon::Error);
1168
			}
1169
			else {
1170
				String ^to = nullptr;
1171
				if ( here ) {
1172
					to = IO::FileInfo(file).DirectoryName;
1173
				}
1174
				else {
1175
					FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
1176
					fbd->Description = "Select the path to extract package to";
1177
					if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
1178
						to = fbd->SelectedPath;
1179
				}
1180
 
1181
				if ( to && to->Length ) {
1182
					// check if theres multiple games in package
1183
					int game = 0;
1184
					if ( p->IsMultipleGamesInPackage() ) {
1185
						SelectGame ^selGame = gcnew SelectGame("Select game to extract package:\n" + file, m_pPackages);
1186
						if ( selGame->ShowDialog(this) == Windows::Forms::DialogResult::OK ) {
1187
							game = selGame->GetGame() + 1;
1188
						}
1189
						else
1190
							to = nullptr;
1191
					}
1192
					else if ( p->IsAnyGameInPackage() ) {
1193
						game = p->FindFirstGameInPackage();
1194
					}
1195
 
1196
					if ( to && to->Length ) {
1197
						if ( p->ExtractAll(CyStringFromSystemString(to), game, true) ) {
1198
							String ^message = "Extracted: " + file + "\nTo: " + to;
1199
							if ( game ) {
1200
								message += "\nGame: " + SystemStringFromCyString(m_pPackages->GetGameExe()->GetGame(game - 1)->sName);
1201
							}
1202
							MessageBox::Show(this, message, "Extracted Package", MessageBoxButtons::OK, MessageBoxIcon::Information);
1203
						}
1204
						else {
1205
							MessageBox::Show(this, "Error: Unable to extract to:\n" + to, "Error Extracting", MessageBoxButtons::OK, MessageBoxIcon::Error);
1206
						}
1207
					}
1208
				}
1209
			}
1210
		}
1211
 
1212
		void SavePackagerScript(String ^file)
1213
		{
1214
			CyString sFile = CyStringFromSystemString(file);
1215
			CyStringList malformed, unknown;
1216
			CBaseFile *package = m_pPackages->LoadPackagerScript(sFile, -1, NULL, &malformed, &unknown);
1217
			if ( package )
1218
			{
1219
				CyString saveto = package->GetFilename();
1220
				saveto = saveto.FindReplace("$DEFAULTDIR", CFileIO(sFile).GetDir() + "/");
1221
				saveto = saveto.FindReplace("$PATH", CFileIO(sFile).GetDir());
1222
				saveto = saveto.FindReplace("\\", "/");
1223
				saveto = saveto.FindReplace("//", "/");
1224
				if ( !saveto.Right(4).Compare(".spk") && package->GetType() != TYPE_XSP )
1225
					saveto += ".spk";
1226
				else if ( !saveto.Right(4).Compare(".xsp") && package->GetType() == TYPE_XSP )
1227
					saveto += ".xsp";
1228
				// write script
1229
				if ( package->WriteFile(saveto) ) {
1230
					String ^message = "Package: " + SystemStringFromCyString(saveto) + " has been created\n";
1231
					if ( package->AutoGenerateUpdateFile() )
1232
						package->CreateUpdateFile(CFileIO(saveto).GetDir());
1233
					CyString exportto = package->GetExportFilename();
1234
					if ( !exportto.Empty() ) {
1235
						exportto = exportto.FindReplace("$DEFAULTDIR", CFileIO(sFile).GetDir() + "/");
1236
						exportto = exportto.FindReplace("$PATH", CFileIO(sFile).GetDir());
1237
						exportto = exportto.FindReplace("\\", "/");
1238
						exportto = exportto.FindReplace("//", "/");
1239
						if ( package->SaveToArchive(exportto, 0) ) {
1240
							message += "\nExported to:\n" + SystemStringFromCyString(exportto) + "\n";
1241
							if ( package->IsAnyGameInPackage() ) {
1242
								for ( int i = 0; i < m_pPackages->GetGameExe()->GetNumGames(); i++ ) {
1243
									if ( package->IsGameInPackage(i + 1) ) {
1244
										CyString exportFile = CFileIO(saveto).GetDir() + "/" + CFileIO(saveto).GetBaseName() + "_" + CBaseFile::ConvertGameToString(i + 1) + "." + CFileIO(exportto).GetFileExtension();
1245
										if ( package->SaveToArchive(exportFile, i + 1) ) {
1246
											message += SystemStringFromCyString(CFileIO(exportFile).GetFilename()) + "\n";
1247
										}
1248
									}
1249
								}
1250
							}
1251
						}
1252
					}
1253
					MessageBox::Show(this, message, "Package Created", MessageBoxButtons::OK, MessageBoxIcon::Information);
1254
				}
1255
				else
1256
					MessageBox::Show(this, "Error: Unable to create package from script\n" + file, "Error Creating Package", MessageBoxButtons::OK, MessageBoxIcon::Error);
1257
			}
1258
		}
1259
 
1260
		void OpenPackagerScript(String ^file)
1261
		{
1262
			CyStringList malformed, unknown;
1263
			CBaseFile *package = m_pPackages->LoadPackagerScript(CyStringFromSystemString(file), SPKCOMPRESS_NONE, NULL, &malformed, &unknown);
1264
			if ( package )
1265
			{
1266
				package->SetDataCompression(SPKCOMPRESS_7ZIP);
1267
				PackageForm ^childForm = this->OpenPackage(true, package, file, "");
1268
				childForm->Text = SystemStringFromCyString(package->GetFilename());
1269
			}
1270
		}
1271
		void OpenPackagerScript()
1272
		{
1273
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
1274
			ofd->Filter = "Packager Script (*.sps)|*.sps";
1275
			ofd->FilterIndex = 1;
1276
			ofd->Title = "Select the packager script to create a package from";
1277
			ofd->RestoreDirectory = true;
1278
			ofd->Multiselect = false;
1279
 
1280
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
1281
				OpenPackagerScript(ofd->FileName);
1282
		}
1283
 
1284
		MultiForm ^OpenPackage(bool display, CMultiSpkFile *package, String ^file, String ^title)
1285
		{
1286
			CyString sFile = CyStringFromSystemString(file);
1287
			TabPage ^tp = gcnew TabPage();
1288
			tp->Text = title;
1289
			tp->ImageIndex = this->imageList1->Images->IndexOfKey(file);
1290
			if ( tp->ImageIndex == -1 )
1291
				tp->ImageIndex = 0;
1292
 
1293
			ToolStripMenuItem ^toolBut = gcnew ToolStripMenuItem((file->Empty) ? title : file, this->imageList1->Images[tp->ImageIndex]);
1294
			MultiForm ^childForm = gcnew MultiForm(this, tabControl1, tp, toolBut, m_pPackages, this->imageList1, this->textList, this->m_settings);
1295
 
1296
			childForm->SetImageLists(this->imageListSmall, this->imageListLarge, this->imageListGames);
1297
			this->windowsToolStripMenuItem->DropDownItems->Add(toolBut);
1298
			childForm->WindowState = FormWindowState::Minimized;
1299
 
1300
			this->ProcessOpen(false, tp, childForm);
1301
			childForm->LoadPackage(package, file);
1302
			this->ProcessOpen(display, tp, childForm);
1303
 
1304
			return childForm;
1305
		}
1306
		PackageForm ^OpenPackage(bool display, CBaseFile *package, String ^file, String ^title)
1307
		{
1308
			CyString sFile = CyStringFromSystemString(file);
1309
 
1310
			if ( this->imageList1->Images->IndexOfKey(file) == -1 )
1311
			{
1312
				if ( package->GetIcon() )
1313
				{
1314
					package->ReadIconFileToMemory();
1315
					CyString sIconFile = CyStringFromSystemString(IO::Path::GetTempPath()) + "\\" + CFileIO(sFile).GetBaseName() + "." + package->GetIconExt();
1316
					if ( package->ExtractFile(package->GetIcon(), CFileIO(sIconFile).GetFullFilename(), false) )
1317
					{
1318
						String ^iconFile = SystemStringFromCyString(sIconFile);
1319
						if ( IO::File::Exists(iconFile) )
1320
						{
1321
							String ^ext = System::IO::FileInfo(iconFile).Extension;
1322
							if ( !String::Compare(ext, "bmp", false) || !String::Compare(ext, "ico", false) )
1323
								this->imageList1->Images->Add(file, Bitmap::FromFile(iconFile));
1324
							else
1325
							{
1326
								Bitmap ^myBitmap = gcnew Bitmap(iconFile);
1327
								if ( myBitmap )
1328
									this->imageList1->Images->Add(file, myBitmap);
1329
							}
1330
						}
1331
					}
1332
				}
1333
			}
1334
 
1335
			TabPage ^tp = gcnew TabPage();
1336
			tp->Text = title;
1337
			tp->ImageIndex = this->imageList1->Images->IndexOfKey(file);
1338
			if ( tp->ImageIndex == -1 )
1339
				tp->ImageIndex = 0;
1340
 
1341
			ToolStripMenuItem ^toolBut = gcnew ToolStripMenuItem((file->Empty) ? title : file, this->imageList1->Images[tp->ImageIndex]);
1342
			PackageForm ^childForm = gcnew PackageForm(this, tabControl1, tp, toolBut, m_pPackages, this->imageList1, this->textList, this->m_settings);
1343
			childForm->SetImageLists(this->imageListSmall, this->imageListLarge, this->imageListGames, this->imageListFiles);
1344
			this->windowsToolStripMenuItem->DropDownItems->Add(toolBut);
1345
			childForm->WindowState = FormWindowState::Minimized;
1346
 
1347
			this->ProcessOpen(false, tp, childForm);
1348
			childForm->LoadPackage(package, file);
1349
			this->ProcessOpen(display, tp, childForm);
1350
 
1351
			return childForm;
1352
		}
1353
 
1354
		void ProcessOpen(bool display, TabPage ^tp, BaseForm ^childForm)
1355
		{
1356
			tp->Parent = tabControl1;
1357
			if ( display || !this->HasChildren )
1358
			{
1359
				tabControl1->SelectedTab = tp;
1360
				tp->Show();
1361
				childForm->Show();
1362
				childForm->WindowState = FormWindowState::Maximized;
1363
				this->UpdateStatus();
1364
			}
1365
		}
1366
 
1367
		void GeneratePackageUpdates()
1368
		{
1369
			FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
1370
			fbd->Description = "Select the path to generate the updates from";
1371
			if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
1372
			{
1373
				int count = 0;
1374
				for ( int type = 0; type < 2; type++ )
1375
				{
1376
					array <System::String ^> ^Files = nullptr;
1377
					if ( type == 0 )
1378
						Files = Directory::GetFiles(fbd->SelectedPath, "*.spk");
1379
					else if ( type == 1 )
1380
						Files = Directory::GetFiles(fbd->SelectedPath, "*.xsp");
1381
					else
1382
						break;
1383
 
1384
					for ( int i = 0; i < Files->Length; i++ )
1385
					{
1386
						CyString file = CyStringFromSystemString(Files[i]);
1387
						int error = 0;
1388
						CBaseFile *p = m_pPackages->OpenPackage(file, &error, 0, SPKREAD_NODATA);
1389
						if ( !p )
1390
							continue;
1391
 
1392
						CyString ufile = p->CreateUpdateFile(CyStringFromSystemString(fbd->SelectedPath));
1393
						if ( !ufile.Empty() )
1394
							++count;
1395
						delete p;
1396
					}
1397
				}
1398
 
1399
				if ( !count )
1400
					MessageBox::Show(this, "No package files with updates found in " + fbd->SelectedPath + "\nSelect a directory that contains spk/xsp files", "No Packages", MessageBoxButtons::OK, MessageBoxIcon::Error);
1401
				else
1402
					MessageBox::Show(this, "Update files generated for " + count + " packages\nDirectory: " + fbd->SelectedPath, "Update File Generated", MessageBoxButtons::OK, MessageBoxIcon::Information);
1403
			}
1404
		}
1405
 
1406
		void GeneratePackageWebList()
1407
		{
1408
			FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
1409
			fbd->Description = "Select the path to generate the list from";
1410
			if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
1411
			{
1412
				CyStringList filedata;
1413
				for ( int type = 0; type < 2; type++ )
1414
				{
1415
					array <System::String ^> ^Files = nullptr;
1416
					if ( type == 0 )
1417
						Files = Directory::GetFiles(fbd->SelectedPath, "*.spk");
1418
					else if ( type == 1 )
1419
						Files = Directory::GetFiles(fbd->SelectedPath, "*.xsp");
1420
					else
1421
						break;
1422
 
1423
					for ( int i = 0; i < Files->Length; i++ )
1424
					{
1425
						CyString file = CyStringFromSystemString(Files[i]);
1426
						int error = 0;
1427
						CBaseFile *p = m_pPackages->OpenPackage(file, &error, 0, SPKREAD_NODATA);
1428
						if ( !p )
1429
							continue;
1430
 
1431
						filedata.PushBack(CPackages::FormatAvailablePackageData(p));
1432
						delete p;
1433
					}
1434
				}
1435
 
1436
				if ( filedata.Empty() )
1437
					MessageBox::Show(this, "No package files found in " + fbd->SelectedPath + "\nSelect a directory that contains spk/xsp files", "No Packages", MessageBoxButtons::OK, MessageBoxIcon::Error);
1438
				else
1439
				{
1440
					CFileIO File(CyStringFromSystemString(fbd->SelectedPath) + "/xpackagedata.dat");
1441
					if ( File.WriteFile(&filedata) )
1442
						MessageBox::Show(this, "Data file generated for " + filedata.Count() + " packages\nDirectory: " + fbd->SelectedPath, "Web File Generated", MessageBoxButtons::OK, MessageBoxIcon::Information);
1443
					else
1444
						MessageBox::Show(this, "Unable to write web data file in " + fbd->SelectedPath, "File Write Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
1445
				}
1446
			}
1447
		}
1448
 
1449
		void Open(System::String ^file, bool display, bool checkExtension)
1450
		{
1451
			CBaseFile *convertFile = NULL;
1452
			if ( checkExtension )
1453
			{
1454
				if ( String::Compare(IO::FileInfo(file).Extension, ".spk") != 0 && String::Compare(IO::FileInfo(file).Extension, ".xsp") != 0 && String::Compare(IO::FileInfo(file).Extension, ".sps") != 0 )
1455
					return;
1456
			}
1457
 
1458
			if ( !System::IO::File::Exists(file) )
1459
			{
1460
				if ( display )
1461
					MessageBox::Show(this, "Unable to open package file:\n" + file + "\n\nFile doesn't exist", "Load Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
1462
				return;
1463
			}
1464
 
1465
			// check if its already open
1466
			if ( this->IsOpen(file) )
1467
			{
1468
				if ( display )
1469
					MessageBox::Show(this, "The package is currently open\n" + file, "Already Open", MessageBoxButtons::OK, MessageBoxIcon::Information);
1470
				return;
1471
			}
1472
 
1473
			// sps
1474
			if ( String::Compare(IO::FileInfo(file).Extension, ".sps") == 0 )
1475
			{
1476
				OpenPackagerScript(file);
1477
				return;
1478
			}
1479
 
1480
			float fVersion;
1481
			CyString sFile = CyStringFromSystemString(file);
1482
			int fileType = CSpkFile::CheckFile(sFile, &fVersion);
1483
 
1484
			if ( fVersion > (float)FILEVERSION )
1485
			{
1486
				if ( display )
1487
					MessageBox::Show(this, "Package file is created with a newer version, unable to open", "Load Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
1488
				return;
1489
			}
1490
 
9 cycrow 1491
			if ( fileType == SPKFILE_INVALID || fileType == SPKFILE_OLD )
1 cycrow 1492
			{
1493
				bool loaded = false;
1494
				if ( String::Compare(IO::FileInfo(file).Extension, ".xsp") == 0 )
1495
				{
1496
					CXspFile *shipFile = new CXspFile;
1497
					loaded = shipFile->ConvertOld(CyStringFromSystemString(file));
1498
					if ( loaded )
1499
					{
1500
						shipFile->SetChanged(true);
1501
						shipFile->SetFilename(CyStringFromSystemString(file));
1502
						convertFile = shipFile;
1503
					}
1504
					else 
1505
						delete shipFile;
1506
				}
9 cycrow 1507
				else if ( String::Compare(IO::FileInfo(file).Extension, ".spk") == 0 )
1508
				{
1509
					CSpkFile *spkFile = CSpkFile::convertFromOld(CyStringFromSystemString(file).ToString());
1510
					if ( spkFile ) {
1511
						loaded = true;
1512
						spkFile->SetChanged(true);
1513
						spkFile->SetFilename(CyStringFromSystemString(file));
1514
						convertFile = spkFile;
1515
					}
1516
				}
1 cycrow 1517
 
1518
				if ( !loaded )
1519
				{
1520
					if ( display )
1521
						MessageBox::Show(this, "Invalid package file:\n" + file + "\n\nDoesn't appear to be a valid package", "Load Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
1522
					return;				
1523
				}
1524
			}
1525
 
1526
			// open multi package
1527
			bool loaded = false;
1528
 
1529
			int error;
1530
			if ( fileType == SPKFILE_MULTI )
1531
			{
1532
				CMultiSpkFile *mspk = m_pPackages->OpenMultiPackage(sFile, &error);
1533
				if ( mspk )
1534
				{
1535
					loaded = true;
1536
					BaseForm ^childForm = this->OpenPackage(display, mspk, file, "");
1537
					childForm->Text = file;
1538
				}
1539
			}
1540
			else
1541
			{
1542
				CBaseFile *package = (convertFile) ? convertFile : m_pPackages->OpenPackage(sFile, &error);
1543
				if ( package )
1544
				{
1545
					loaded = true;
1546
					PackageForm ^childForm = this->OpenPackage(display, package, file, "");
1547
					if ( convertFile )
1548
					{
1549
						convertFile->SetChanged(true);
1550
						childForm->UpdateChanged();
1551
					}
1552
				}
1553
			}
1554
 
1555
			if ( loaded )
1556
			{
1557
				// adjust the loaded list
1558
				sFile.FindReplace("/", "\\");
1559
				sFile.RemoveChar(9);
1560
				sFile.RemoveChar('\r');
1561
				sFile.RemoveChar('\n');
1562
				m_pLoadedList->Remove(sFile, true);
1563
				m_pLoadedList->PushFront(sFile);
1564
 
1565
				while ( m_pLoadedList->Count() > 15 )
1566
					m_pLoadedList->PopBack();
1567
 
1568
				this->SaveData();
1569
 
1570
				this->UpdateDropDownOpen();
1571
			}	
1572
			else
1573
			{
1574
				if ( display )
1575
				{
1576
					System::String ^sError = "Unknown Error (" + SystemStringFromCyString(CyString::Number(error)) + ")";
1577
					switch ( error )
1578
					{
1579
						case INSTALLERR_OLD:
1580
							sError = "Old unsupported package file";
1581
							break;
1582
						case INSTALLERR_INVALID:
1583
							sError = "Invalid Package File";
1584
							break;
1585
						case INSTALLERR_NOMULTI:
1586
							sError = "Multi-Packages not currently supported";
1587
							break;
1588
					}
1589
					MessageBox::Show(this, "Unable to open package file:\n" + file + "\n\nError: " + sError, "Load Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
1590
				}
1591
			}
1592
		}
1593
 
1594
		void NewPackage(bool ship)
1595
		{
1596
			 TabPage ^tp = gcnew TabPage();
1597
  			 tp->ImageIndex = 0;
1598
			 if ( ship )
1599
				tp->Text = "New Ship";
1600
			 else
1601
				tp->Text = "New Package";
1602
			 ToolStripMenuItem ^toolBut = gcnew ToolStripMenuItem(tp->Text, this->imageList1->Images[tp->ImageIndex]);
1603
 			 this->windowsToolStripMenuItem->DropDownItems->Add(toolBut);
1604
			 PackageForm ^childForm = gcnew PackageForm(this, tabControl1, tp, toolBut, m_pPackages, this->imageList1, this->textList, this->m_settings);
1605
			 childForm->SetImageLists(this->imageListSmall, this->imageListLarge, this->imageListGames, this->imageListFiles);
1606
			 tp->Parent = tabControl1;
1607
			 tabControl1->SelectedTab = tp;
1608
 
1609
			 if ( ship )
1610
				childForm->CreateShip();
1611
			 else
1612
				childForm->CreatePackage();
1613
 
1614
			 childForm->WindowState = FormWindowState::Maximized;
1615
			 tp->Show();
1616
			 childForm->Show();
1617
		}
1618
 
1619
		void NewMultiPackage()
1620
		{
1621
			 TabPage ^tp = gcnew TabPage();
1622
  			 tp->ImageIndex = 0;
1623
			 tp->Text = "New Mutli Package";
1624
			 ToolStripMenuItem ^toolBut = gcnew ToolStripMenuItem(tp->Text, this->imageList1->Images[tp->ImageIndex]);
1625
 			 this->windowsToolStripMenuItem->DropDownItems->Add(toolBut);
1626
			 MultiForm ^childForm = gcnew MultiForm(this, tabControl1, tp, toolBut, m_pPackages, this->imageList1, this->textList, this->m_settings);
1627
			 childForm->SetImageLists(this->imageListSmall, this->imageListLarge, this->imageListGames);
1628
			 tp->Parent = tabControl1;
1629
			 tabControl1->SelectedTab = tp;
1630
 
1631
			 childForm->CreatePackage();
1632
 
1633
			 childForm->WindowState = FormWindowState::Maximized;
1634
			 tp->Show();
1635
			 childForm->Show();
1636
 
1637
		}
1638
 
1639
		void CloseAll()
1640
		{
1641
			cli::array<System::Windows::Forms::Form ^> ^children = this->MdiChildren;
1642
			for ( int i = 0; i < children->Length; i++ )
1643
			{
1644
				delete ((BaseForm ^)children[i])->TabPage();
1645
				//((BaseForm ^)children[i])->
1646
				delete children[i];
1647
			}
1648
			this->UpdateDisplay();
1649
		}
1650
 
1651
		void CloseEvent(System::Object ^Sender, System::EventArgs ^E) 
1652
		{
1653
			this->CloseAll();
1654
			this->SaveData();
1655
		}
1656
 
1657
		void UpdateDropDownOpen()
1658
		{
1659
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
1660
 
1661
			// clear them all
1662
			this->toolStripSplitButton1->DropDownItems->Clear();
1663
			this->openToolStripMenuItem->DropDownItems->Clear();
1664
 
1665
			System::Windows::Forms::ToolStripMenuItem ^openPackage = gcnew System::Windows::Forms::ToolStripMenuItem;
1666
			openPackage->Text = "Open Package";
1667
			openPackage->Tag = "$PACKAGE";
1668
			openPackage->Click += gcnew System::EventHandler(this, &Form1::Event_Open);
1669
			openPackage->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripSplitButton1.Image")));
1670
			this->openToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripSplitButton1.Image")));
1671
			this->openToolStripMenuItem->DropDownItems->Add(openPackage);
1672
 
1673
			System::Windows::Forms::ToolStripMenuItem ^newItem = gcnew System::Windows::Forms::ToolStripMenuItem;
1674
			newItem->Text = "Open Directory";
1675
			newItem->Tag = "$DIR";
1676
			newItem->Click += gcnew System::EventHandler(this, &Form1::Event_Open);
1677
			this->toolStripSplitButton1->DropDownItems->Add(newItem);
1678
 
1679
			// add all none open items
1680
			bool sep = false;
1681
			for ( SStringList *str = m_pLoadedList->Head(); str; str = str->next )
1682
			{
1683
				// check if we have it open
1684
				System::String ^sFile = SystemStringFromCyString(str->str.findreplace("/", "\\"));
1685
				if ( this->IsOpen(sFile) )
1686
					continue;
1687
				if ( this->IsOpen(SystemStringFromCyString(str->str.findreplace("\\", "/"))) )
1688
					continue;
1689
 
1690
				if ( !IO::File::Exists(sFile) )
1691
					continue;
1692
 
1693
				if ( !sep )
1694
				{
1695
					sep = true;
1696
					this->toolStripSplitButton1->DropDownItems->Add(gcnew System::Windows::Forms::ToolStripSeparator());
1697
					this->openToolStripMenuItem->DropDownItems->Add(gcnew System::Windows::Forms::ToolStripSeparator());
1698
				}
1699
 
1700
				// work out the type
1701
				float fVersion;
1702
				int iconType = -1;
1703
				int check = CBaseFile::CheckFile(str->str, &fVersion);
1704
				switch ( check )
1705
				{
1706
					case SPKFILE_BASE:
1707
						iconType = 5;
1708
						break;
1709
					case SPKFILE_SINGLE:
1710
						iconType = 0;
1711
						break;
1712
					case SPKFILE_SINGLESHIP:
1713
						iconType = 1;
1714
						break;
1715
					case SPKFILE_MULTI:
1716
						iconType = 4;
1717
						break;
1718
				}
1719
 
1720
				// otherwise add it to the list
1721
				System::Windows::Forms::ToolStripMenuItem ^newItem = gcnew System::Windows::Forms::ToolStripMenuItem;
1722
				newItem->Text = sFile;
1723
				newItem->Tag = newItem->Text;
1724
				newItem->Click += gcnew System::EventHandler(this, &Form1::Event_Open);
1725
				if ( iconType > -1 )
1726
					newItem->Image = this->imageList1->Images[iconType];
1727
				this->toolStripSplitButton1->DropDownItems->Add(newItem);
1728
 
1729
				System::Windows::Forms::ToolStripMenuItem ^newItem2 = gcnew System::Windows::Forms::ToolStripMenuItem;
1730
				newItem2->Text = sFile;
1731
				newItem2->Tag = newItem->Text;
1732
				newItem2->Click += gcnew System::EventHandler(this, &Form1::Event_Open);
1733
				if ( iconType > -1 )
1734
					newItem2->Image = this->imageList1->Images[iconType];
1735
				this->openToolStripMenuItem->DropDownItems->Add(newItem2);
1736
			}
1737
		}
1738
 
1739
		bool IsOpen(System::String ^file)
1740
		{
1741
			 cli::array<System::Windows::Forms::Form ^> ^children = this->MdiChildren;
1742
			 for ( int i = 0; i < children->Length; i++ )
1743
			 {
1744
				 BaseForm ^childForm = (BaseForm ^)children[i];
1745
				 if ( childForm->IsClosing() )
1746
					 continue;
1747
				 if ( childForm->CheckFilename(file) )
1748
					 return true;
1749
			 }
1750
 
1751
			 return false;
1752
		}
1753
 
1754
		void Save()
1755
		{
1756
			 cli::array<System::Windows::Forms::Form ^> ^children = this->MdiChildren;
1757
			 for ( int i = 0; i < children->Length; i++ )
1758
			 {
1759
				 BaseForm ^childForm = (BaseForm ^)children[i];
1760
				 if ( childForm->TabPage()->Equals(tabControl1->SelectedTab) )
1761
				 {
1762
					 if ( childForm->GetFormType() == FORMTYPE_SINGLE )
1763
						((PackageForm ^)childForm)->Save();
1764
					 else if ( childForm->GetFormType() == FORMTYPE_MULTI )
1765
						((MultiForm ^)childForm)->Save();
1766
					 else
1767
						childForm->Save();
1768
					 this->UpdateDropDownOpen();
1769
					 break;
1770
				 }
1771
			 }
1772
		}
1773
 
1774
		void SaveAs()
1775
		{
1776
			 cli::array<System::Windows::Forms::Form ^> ^children = this->MdiChildren;
1777
			 for ( int i = 0; i < children->Length; i++ )
1778
			 {
1779
				 BaseForm ^childForm = (BaseForm ^)children[i];
1780
				 if ( childForm->TabPage()->Equals(tabControl1->SelectedTab) )
1781
				 {
1782
					 if ( childForm->GetFormType() == FORMTYPE_SINGLE )
1783
						((PackageForm ^)childForm)->SaveAs();
1784
					 else if ( childForm->GetFormType() == FORMTYPE_MULTI )
1785
						((MultiForm ^)childForm)->SaveAs();
1786
					 else
1787
						childForm->SaveAs();
1788
					 this->UpdateDropDownOpen();
1789
					 break;
1790
				 }
1791
			 }
1792
		}
1793
 
1794
		void PackageCreationWizard()
1795
		{
1796
			MessageBox::Show(this, "The creation wizard is currently not available", "Feature Missing", MessageBoxButtons::OK, MessageBoxIcon::Error);
1797
			return;
1798
 
1799
			CreationWizard ^wizard = gcnew CreationWizard();
1800
			if ( wizard->ShowDialog(this) == Windows::Forms::DialogResult::OK )
1801
			{
1802
			}
1803
		}
1804
 
1805
		void SaveData()
1806
		{
1807
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
1808
			CFileIO Config(CyStringFromSystemString(mydoc) + "/Egosoft/creator.dat");
1809
			CyStringList lines;
1810
 
1811
			if ( this->WindowState == FormWindowState::Normal )
1812
			{
1813
				lines.PushBack(CyString("CreatorSize:") + (long)this->Size.Width + " " + (long)this->Size.Height);
1814
				lines.PushBack(CyString("CreatorPos:") + (long)this->Location.X + " " + (long)this->Location.Y);
1815
			}
1816
			else
1817
			{
1818
				lines.PushBack(CyString("CreatorPos:") + (long)this->RestoreBounds.Location.X + " " + (long)this->RestoreBounds.Location.Y);
1819
				lines.PushBack(CyString("CreatorSize:") + (long)this->RestoreBounds.Size.Width + " " + (long)this->RestoreBounds.Size.Height);
1820
			}
1821
 
1822
			if ( this->WindowState == FormWindowState::Maximized )
1823
				lines.PushBack("CreatorMax:");
1824
 
1825
			for ( SStringList *str = m_pLoadedList->Head(); str; str = str->next )
1826
				lines.PushBack(CyString("Loaded:") + str->data + " " + str->str);
1827
			for ( SGameDir *gd = m_pGameDir->First(); gd; gd = m_pGameDir->Next() )
1828
				lines.PushBack(CyString("GameDir:") + gd->sDir + ";" + gd->sGame + ((gd->bLoad) ? ";1" : ";0"));
1829
			if ( m_settings->bGenerateUpdate )
1830
				lines.PushBack("GenerateUpdate:");
1831
 
1832
			Config.WriteFile(&lines);
1833
		}
1834
 
1835
		void LoadData()
1836
		{
1837
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
1838
			CFileIO Config;
1839
			if ( Config.Open(CyStringFromSystemString(mydoc) + "/Egosoft/creator.dat") )
1840
			{
1841
				std::vector<CyString> *lines = Config.ReadLines();
1842
				if ( lines )
1843
				{
1844
					for ( int i = 0; i < (int)lines->size(); i++ )
1845
					{
1846
						CyString line(lines->at(i));
1847
						CyString start = line.GetToken(":", 1, 1).ToLower();
1848
						CyString rest = line.GetToken(":", 2).RemoveFirstSpace();
1849
						if ( start.Compare("CreatorSize") )
1850
							this->Size = System::Drawing::Size(rest.GetToken(" ", 1, 1).ToInt(), rest.GetToken(" ", 2, 2).ToInt());
1851
						else if ( start.Compare("CreatorPos") )
1852
						{
1853
							m_iLocX = rest.GetToken(" ", 1, 1).ToInt();
1854
							m_iLocY = rest.GetToken(" ", 2, 2).ToInt();
1855
						}
1856
						else if ( start.Compare("Loaded") )
1857
							m_pLoadedList->PushBack(rest);
1858
						else if ( start.Compare("CreatorMax") )
1859
							this->WindowState = FormWindowState::Maximized;
1860
						else if ( start.Compare("GenerateUpdate") )
1861
							m_settings->bGenerateUpdate = true;
1862
						else if ( start.Compare("GameDir") )
1863
						{
1864
							SGameDir *gd = new SGameDir;
1865
							gd->sDir = rest.GetToken(";", 1, 1);
1866
							gd->sGame = rest.GetToken(";", 2, 2);
1867
							gd->bLoad = rest.GetToken(";", 3, 3).ToBool();
1868
							m_pGameDir->push_back(gd);
1869
						}
1870
					}
1871
 
1872
					delete lines;
1873
				}
1874
			}
1875
		}
1876
 
1877
 
1878
		void LoadText(bool center, bool reload)
1879
		{
1880
			if ( m_bTextLoaded && !reload )
1881
				return;
1882
			m_bTextLoaded = true;
1883
 
1884
			textList->Clear();
1885
			if ( m_pGameDir->empty() )
1886
				return;
1887
 
1888
			Creator::LoadText ^load = gcnew Creator::LoadText(m_pGameDir, m_pPackages, textList);
1889
			if ( center )
1890
				load->StartPosition = Windows::Forms::FormStartPosition::CenterScreen;
1891
 
1892
			load->ShowDialog(this);
1893
		}
1894
 
1895
 
1896
private: System::ComponentModel::IContainer^  components;
1897
 
1898
 
1899
		/// <summary>
1900
		/// Required designer variable.
1901
		/// </summary>
1902
 
1903
 
1904
#pragma region Windows Form Designer generated code
1905
		/// <summary>
1906
		/// Required method for Designer support - do not modify
1907
		/// the contents of this method with the code editor.
1908
		/// </summary>
1909
		void InitializeComponent(void)
1910
		{
1911
			this->components = (gcnew System::ComponentModel::Container());
1912
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
1913
			this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
1914
			this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1915
			this->newToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1916
			this->packageToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1917
			this->shipToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1918
			this->toolStripSeparator5 = (gcnew System::Windows::Forms::ToolStripSeparator());
1919
			this->fromPackagerScriptToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
1920
			this->importShipFromModToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
1921
			this->toolStripSeparator6 = (gcnew System::Windows::Forms::ToolStripSeparator());
1922
			this->packageCreationWizardToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1923
			this->openToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1924
			this->saveToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1925
			this->saveAsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1926
			this->toolStripSeparator2 = (gcnew System::Windows::Forms::ToolStripSeparator());
1927
			this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1928
			this->windowsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1929
			this->layoutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1930
			this->cascadeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1931
			this->horizontalToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1932
			this->verticalToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1933
			this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
1934
			this->settingsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1935
			this->configToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1936
			this->toolsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1937
			this->modMergeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1938
			this->modDiffToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
1939
			this->toolStripSeparator10 = (gcnew System::Windows::Forms::ToolStripSeparator());
1940
			this->generatePackageWebListToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
1941
			this->PanelTab = (gcnew System::Windows::Forms::Panel());
1942
			this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
1943
			this->imageList1 = (gcnew System::Windows::Forms::ImageList(this->components));
1944
			this->button1 = (gcnew System::Windows::Forms::Button());
1945
			this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip());
1946
			this->toolStripButton1 = (gcnew System::Windows::Forms::ToolStripDropDownButton());
1947
			this->packageToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
1948
			this->shipToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
1949
			this->multiPackageToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1950
			this->toolStripSeparator4 = (gcnew System::Windows::Forms::ToolStripSeparator());
1951
			this->fromPackagerScriptToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1952
			this->fromArchiveToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1953
			this->importShipFromModToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1954
			this->toolStripSeparator7 = (gcnew System::Windows::Forms::ToolStripSeparator());
1955
			this->packageCreationWizardToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
1956
			this->toolStripSplitButton1 = (gcnew System::Windows::Forms::ToolStripSplitButton());
1957
			this->toolStripSeparator3 = (gcnew System::Windows::Forms::ToolStripSeparator());
1958
			this->toolStripButton2 = (gcnew System::Windows::Forms::ToolStripButton());
1959
			this->toolStripSeparator8 = (gcnew System::Windows::Forms::ToolStripSeparator());
1960
			this->toolStripDropDownButton1 = (gcnew System::Windows::Forms::ToolStripDropDownButton());
1961
			this->modMergeToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
1962
			this->modDiffToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1963
			this->toolStripSeparator9 = (gcnew System::Windows::Forms::ToolStripSeparator());
1964
			this->generatePackageWebListToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1965
			this->generatePackageUpdatesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1966
			this->toolStripSeparator11 = (gcnew System::Windows::Forms::ToolStripSeparator());
1967
			this->fileExplorerToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
1968
			this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
1969
			this->statusStrip1 = (gcnew System::Windows::Forms::StatusStrip());
1970
			this->StatusFiles = (gcnew System::Windows::Forms::ToolStripStatusLabel());
1971
			this->imageListGames = (gcnew System::Windows::Forms::ImageList(this->components));
1972
			this->toolTip1 = (gcnew System::Windows::Forms::ToolTip(this->components));
1973
			this->imageListSmall = (gcnew System::Windows::Forms::ImageList(this->components));
1974
			this->imageListLarge = (gcnew System::Windows::Forms::ImageList(this->components));
1975
			this->imageListFiles = (gcnew System::Windows::Forms::ImageList(this->components));
1976
			this->backgroundWorker1 = (gcnew System::ComponentModel::BackgroundWorker());
1977
			this->menuStrip1->SuspendLayout();
1978
			this->PanelTab->SuspendLayout();
1979
			this->toolStrip1->SuspendLayout();
1980
			this->statusStrip1->SuspendLayout();
1981
			this->SuspendLayout();
1982
			// 
1983
			// menuStrip1
1984
			// 
1985
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {this->fileToolStripMenuItem, 
1986
				this->windowsToolStripMenuItem, this->settingsToolStripMenuItem, this->toolsToolStripMenuItem});
1987
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
1988
			this->menuStrip1->Name = L"menuStrip1";
1989
			this->menuStrip1->Size = System::Drawing::Size(747, 24);
1990
			this->menuStrip1->TabIndex = 2;
1991
			this->menuStrip1->Text = L"menuStrip1";
1992
			// 
1993
			// fileToolStripMenuItem
1994
			// 
1995
			this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(6) {this->newToolStripMenuItem, 
1996
				this->openToolStripMenuItem, this->saveToolStripMenuItem, this->saveAsToolStripMenuItem, this->toolStripSeparator2, this->exitToolStripMenuItem});
1997
			this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
1998
			this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20);
1999
			this->fileToolStripMenuItem->Text = L"&File";
2000
			// 
2001
			// newToolStripMenuItem
2002
			// 
2003
			this->newToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(7) {this->packageToolStripMenuItem, 
2004
				this->shipToolStripMenuItem, this->toolStripSeparator5, this->fromPackagerScriptToolStripMenuItem1, this->importShipFromModToolStripMenuItem1, 
2005
				this->toolStripSeparator6, this->packageCreationWizardToolStripMenuItem});
2006
			this->newToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"newToolStripMenuItem.Image")));
2007
			this->newToolStripMenuItem->Name = L"newToolStripMenuItem";
2008
			this->newToolStripMenuItem->Size = System::Drawing::Size(150, 22);
2009
			this->newToolStripMenuItem->Text = L"&New";
2010
			// 
2011
			// packageToolStripMenuItem
2012
			// 
2013
			this->packageToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"packageToolStripMenuItem.Image")));
2014
			this->packageToolStripMenuItem->Name = L"packageToolStripMenuItem";
2015
			this->packageToolStripMenuItem->Size = System::Drawing::Size(205, 22);
2016
			this->packageToolStripMenuItem->Text = L"Package";
2017
			this->packageToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::packageToolStripMenuItem_Click);
2018
			// 
2019
			// shipToolStripMenuItem
2020
			// 
2021
			this->shipToolStripMenuItem->Name = L"shipToolStripMenuItem";
2022
			this->shipToolStripMenuItem->Size = System::Drawing::Size(205, 22);
2023
			this->shipToolStripMenuItem->Text = L"Ship";
2024
			this->shipToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::shipToolStripMenuItem_Click);
2025
			// 
2026
			// toolStripSeparator5
2027
			// 
2028
			this->toolStripSeparator5->Name = L"toolStripSeparator5";
2029
			this->toolStripSeparator5->Size = System::Drawing::Size(202, 6);
2030
			// 
2031
			// fromPackagerScriptToolStripMenuItem1
2032
			// 
2033
			this->fromPackagerScriptToolStripMenuItem1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"fromPackagerScriptToolStripMenuItem1.Image")));
2034
			this->fromPackagerScriptToolStripMenuItem1->Name = L"fromPackagerScriptToolStripMenuItem1";
2035
			this->fromPackagerScriptToolStripMenuItem1->Size = System::Drawing::Size(205, 22);
2036
			this->fromPackagerScriptToolStripMenuItem1->Text = L"From Packager Script";
2037
			this->fromPackagerScriptToolStripMenuItem1->Click += gcnew System::EventHandler(this, &Form1::fromPackagerScriptToolStripMenuItem1_Click);
2038
			// 
2039
			// importShipFromModToolStripMenuItem1
2040
			// 
2041
			this->importShipFromModToolStripMenuItem1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"importShipFromModToolStripMenuItem1.Image")));
2042
			this->importShipFromModToolStripMenuItem1->Name = L"importShipFromModToolStripMenuItem1";
2043
			this->importShipFromModToolStripMenuItem1->Size = System::Drawing::Size(205, 22);
2044
			this->importShipFromModToolStripMenuItem1->Text = L"Import Ship From Mod";
2045
			this->importShipFromModToolStripMenuItem1->Click += gcnew System::EventHandler(this, &Form1::importShipFromModToolStripMenuItem1_Click);
2046
			// 
2047
			// toolStripSeparator6
2048
			// 
2049
			this->toolStripSeparator6->Name = L"toolStripSeparator6";
2050
			this->toolStripSeparator6->Size = System::Drawing::Size(202, 6);
2051
			// 
2052
			// packageCreationWizardToolStripMenuItem
2053
			// 
2054
			this->packageCreationWizardToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"packageCreationWizardToolStripMenuItem.Image")));
2055
			this->packageCreationWizardToolStripMenuItem->Name = L"packageCreationWizardToolStripMenuItem";
2056
			this->packageCreationWizardToolStripMenuItem->Size = System::Drawing::Size(205, 22);
2057
			this->packageCreationWizardToolStripMenuItem->Text = L"Package Creation Wizard";
2058
			this->packageCreationWizardToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::packageCreationWizardToolStripMenuItem_Click);
2059
			// 
2060
			// openToolStripMenuItem
2061
			// 
2062
			this->openToolStripMenuItem->Name = L"openToolStripMenuItem";
2063
			this->openToolStripMenuItem->Size = System::Drawing::Size(150, 22);
2064
			this->openToolStripMenuItem->Text = L"&Open Package";
2065
			// 
2066
			// saveToolStripMenuItem
2067
			// 
2068
			this->saveToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"saveToolStripMenuItem.Image")));
2069
			this->saveToolStripMenuItem->Name = L"saveToolStripMenuItem";
2070
			this->saveToolStripMenuItem->Size = System::Drawing::Size(150, 22);
2071
			this->saveToolStripMenuItem->Text = L"&Save";
2072
			this->saveToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveToolStripMenuItem_Click);
2073
			// 
2074
			// saveAsToolStripMenuItem
2075
			// 
2076
			this->saveAsToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"saveAsToolStripMenuItem.Image")));
2077
			this->saveAsToolStripMenuItem->Name = L"saveAsToolStripMenuItem";
2078
			this->saveAsToolStripMenuItem->Size = System::Drawing::Size(150, 22);
2079
			this->saveAsToolStripMenuItem->Text = L"Save &As";
2080
			this->saveAsToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveAsToolStripMenuItem_Click);
2081
			// 
2082
			// toolStripSeparator2
2083
			// 
2084
			this->toolStripSeparator2->Name = L"toolStripSeparator2";
2085
			this->toolStripSeparator2->Size = System::Drawing::Size(147, 6);
2086
			// 
2087
			// exitToolStripMenuItem
2088
			// 
2089
			this->exitToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"exitToolStripMenuItem.Image")));
2090
			this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
2091
			this->exitToolStripMenuItem->Size = System::Drawing::Size(150, 22);
2092
			this->exitToolStripMenuItem->Text = L"E&xit";
2093
			this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::exitToolStripMenuItem_Click);
2094
			// 
2095
			// windowsToolStripMenuItem
2096
			// 
2097
			this->windowsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->layoutToolStripMenuItem, 
2098
				this->toolStripSeparator1});
2099
			this->windowsToolStripMenuItem->Name = L"windowsToolStripMenuItem";
2100
			this->windowsToolStripMenuItem->Size = System::Drawing::Size(68, 20);
2101
			this->windowsToolStripMenuItem->Text = L"&Windows";
2102
			// 
2103
			// layoutToolStripMenuItem
2104
			// 
2105
			this->layoutToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->cascadeToolStripMenuItem, 
2106
				this->horizontalToolStripMenuItem, this->verticalToolStripMenuItem});
2107
			this->layoutToolStripMenuItem->Name = L"layoutToolStripMenuItem";
2108
			this->layoutToolStripMenuItem->Size = System::Drawing::Size(110, 22);
2109
			this->layoutToolStripMenuItem->Text = L"Layout";
2110
			// 
2111
			// cascadeToolStripMenuItem
2112
			// 
2113
			this->cascadeToolStripMenuItem->Name = L"cascadeToolStripMenuItem";
2114
			this->cascadeToolStripMenuItem->Size = System::Drawing::Size(151, 22);
2115
			this->cascadeToolStripMenuItem->Text = L"Cascade";
2116
			this->cascadeToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::cascadeToolStripMenuItem_Click);
2117
			// 
2118
			// horizontalToolStripMenuItem
2119
			// 
2120
			this->horizontalToolStripMenuItem->Name = L"horizontalToolStripMenuItem";
2121
			this->horizontalToolStripMenuItem->Size = System::Drawing::Size(151, 22);
2122
			this->horizontalToolStripMenuItem->Text = L"Tile Horizontal";
2123
			this->horizontalToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::horizontalToolStripMenuItem_Click);
2124
			// 
2125
			// verticalToolStripMenuItem
2126
			// 
2127
			this->verticalToolStripMenuItem->Name = L"verticalToolStripMenuItem";
2128
			this->verticalToolStripMenuItem->Size = System::Drawing::Size(151, 22);
2129
			this->verticalToolStripMenuItem->Text = L"Tile Vertical";
2130
			this->verticalToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::verticalToolStripMenuItem_Click);
2131
			// 
2132
			// toolStripSeparator1
2133
			// 
2134
			this->toolStripSeparator1->Name = L"toolStripSeparator1";
2135
			this->toolStripSeparator1->Size = System::Drawing::Size(107, 6);
2136
			// 
2137
			// settingsToolStripMenuItem
2138
			// 
2139
			this->settingsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->configToolStripMenuItem});
2140
			this->settingsToolStripMenuItem->Name = L"settingsToolStripMenuItem";
2141
			this->settingsToolStripMenuItem->Size = System::Drawing::Size(61, 20);
2142
			this->settingsToolStripMenuItem->Text = L"Settings";
2143
			// 
2144
			// configToolStripMenuItem
2145
			// 
2146
			this->configToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"configToolStripMenuItem.Image")));
2147
			this->configToolStripMenuItem->Name = L"configToolStripMenuItem";
2148
			this->configToolStripMenuItem->Size = System::Drawing::Size(110, 22);
2149
			this->configToolStripMenuItem->Text = L"Config";
2150
			this->configToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::configToolStripMenuItem_Click);
2151
			// 
2152
			// toolsToolStripMenuItem
2153
			// 
2154
			this->toolsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {this->modMergeToolStripMenuItem, 
2155
				this->modDiffToolStripMenuItem1, this->toolStripSeparator10, this->generatePackageWebListToolStripMenuItem1});
2156
			this->toolsToolStripMenuItem->Name = L"toolsToolStripMenuItem";
2157
			this->toolsToolStripMenuItem->Size = System::Drawing::Size(48, 20);
2158
			this->toolsToolStripMenuItem->Text = L"Tools";
2159
			// 
2160
			// modMergeToolStripMenuItem
2161
			// 
2162
			this->modMergeToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"modMergeToolStripMenuItem.Image")));
2163
			this->modMergeToolStripMenuItem->Name = L"modMergeToolStripMenuItem";
2164
			this->modMergeToolStripMenuItem->Size = System::Drawing::Size(216, 22);
2165
			this->modMergeToolStripMenuItem->Text = L"Mod Merge";
2166
			this->modMergeToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::modMergeToolStripMenuItem_Click);
2167
			// 
2168
			// modDiffToolStripMenuItem1
2169
			// 
2170
			this->modDiffToolStripMenuItem1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"modDiffToolStripMenuItem1.Image")));
2171
			this->modDiffToolStripMenuItem1->Name = L"modDiffToolStripMenuItem1";
2172
			this->modDiffToolStripMenuItem1->Size = System::Drawing::Size(216, 22);
2173
			this->modDiffToolStripMenuItem1->Text = L"Mod Diff";
2174
			this->modDiffToolStripMenuItem1->Click += gcnew System::EventHandler(this, &Form1::modDiffToolStripMenuItem1_Click);
2175
			// 
2176
			// toolStripSeparator10
2177
			// 
2178
			this->toolStripSeparator10->Name = L"toolStripSeparator10";
2179
			this->toolStripSeparator10->Size = System::Drawing::Size(213, 6);
2180
			// 
2181
			// generatePackageWebListToolStripMenuItem1
2182
			// 
2183
			this->generatePackageWebListToolStripMenuItem1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"generatePackageWebListToolStripMenuItem1.Image")));
2184
			this->generatePackageWebListToolStripMenuItem1->Name = L"generatePackageWebListToolStripMenuItem1";
2185
			this->generatePackageWebListToolStripMenuItem1->Size = System::Drawing::Size(216, 22);
2186
			this->generatePackageWebListToolStripMenuItem1->Text = L"Generate Package Web List";
2187
			this->generatePackageWebListToolStripMenuItem1->Click += gcnew System::EventHandler(this, &Form1::generatePackageWebListToolStripMenuItem1_Click);
2188
			// 
2189
			// PanelTab
2190
			// 
2191
			this->PanelTab->Controls->Add(this->tabControl1);
2192
			this->PanelTab->Controls->Add(this->button1);
2193
			this->PanelTab->Dock = System::Windows::Forms::DockStyle::Top;
2194
			this->PanelTab->Location = System::Drawing::Point(0, 63);
2195
			this->PanelTab->Name = L"PanelTab";
2196
			this->PanelTab->Size = System::Drawing::Size(747, 27);
2197
			this->PanelTab->TabIndex = 6;
2198
			// 
2199
			// tabControl1
2200
			// 
2201
			this->tabControl1->Dock = System::Windows::Forms::DockStyle::Fill;
2202
			this->tabControl1->ImageList = this->imageList1;
2203
			this->tabControl1->Location = System::Drawing::Point(0, 0);
2204
			this->tabControl1->Name = L"tabControl1";
2205
			this->tabControl1->SelectedIndex = 0;
2206
			this->tabControl1->Size = System::Drawing::Size(726, 27);
2207
			this->tabControl1->TabIndex = 3;
2208
			this->tabControl1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::tabControl1_SelectedIndexChanged_1);
2209
			// 
2210
			// imageList1
2211
			// 
2212
			this->imageList1->ImageStream = (cli::safe_cast<System::Windows::Forms::ImageListStreamer^  >(resources->GetObject(L"imageList1.ImageStream")));
2213
			this->imageList1->TransparentColor = System::Drawing::Color::Transparent;
2214
			this->imageList1->Images->SetKeyName(0, L"standard");
2215
			this->imageList1->Images->SetKeyName(1, L"ship");
2216
			this->imageList1->Images->SetKeyName(2, L"fake");
2217
			this->imageList1->Images->SetKeyName(3, L"library");
2218
			this->imageList1->Images->SetKeyName(4, L"multi");
2219
			this->imageList1->Images->SetKeyName(5, L"normal");
2220
			this->imageList1->Images->SetKeyName(6, L"update");
2221
			this->imageList1->Images->SetKeyName(7, L"patch");
2222
			this->imageList1->Images->SetKeyName(8, L"start");
2223
			// 
2224
			// button1
2225
			// 
2226
			this->button1->Dock = System::Windows::Forms::DockStyle::Right;
2227
			this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
2228
				static_cast<System::Byte>(0)));
2229
			this->button1->ForeColor = System::Drawing::Color::Red;
2230
			this->button1->Location = System::Drawing::Point(726, 0);
2231
			this->button1->Name = L"button1";
2232
			this->button1->Size = System::Drawing::Size(21, 27);
2233
			this->button1->TabIndex = 4;
2234
			this->button1->Text = L"X";
2235
			this->button1->UseVisualStyleBackColor = true;
2236
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
2237
			// 
2238
			// toolStrip1
2239
			// 
2240
			this->toolStrip1->GripStyle = System::Windows::Forms::ToolStripGripStyle::Hidden;
2241
			this->toolStrip1->ImageScalingSize = System::Drawing::Size(32, 32);
2242
			this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(6) {this->toolStripButton1, 
2243
				this->toolStripSplitButton1, this->toolStripSeparator3, this->toolStripButton2, this->toolStripSeparator8, this->toolStripDropDownButton1});
2244
			this->toolStrip1->LayoutStyle = System::Windows::Forms::ToolStripLayoutStyle::HorizontalStackWithOverflow;
2245
			this->toolStrip1->Location = System::Drawing::Point(0, 24);
2246
			this->toolStrip1->Name = L"toolStrip1";
2247
			this->toolStrip1->Size = System::Drawing::Size(747, 39);
2248
			this->toolStrip1->TabIndex = 7;
2249
			this->toolStrip1->Text = L"toolStrip1";
2250
			// 
2251
			// toolStripButton1
2252
			// 
2253
			this->toolStripButton1->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(9) {this->packageToolStripMenuItem1, 
2254
				this->shipToolStripMenuItem1, this->multiPackageToolStripMenuItem, this->toolStripSeparator4, this->fromPackagerScriptToolStripMenuItem, 
2255
				this->fromArchiveToolStripMenuItem, this->importShipFromModToolStripMenuItem, this->toolStripSeparator7, this->packageCreationWizardToolStripMenuItem1});
2256
			this->toolStripButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton1.Image")));
2257
			this->toolStripButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
2258
			this->toolStripButton1->Name = L"toolStripButton1";
2259
			this->toolStripButton1->Size = System::Drawing::Size(76, 36);
2260
			this->toolStripButton1->Text = L"New";
2261
			// 
2262
			// packageToolStripMenuItem1
2263
			// 
2264
			this->packageToolStripMenuItem1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"packageToolStripMenuItem1.Image")));
2265
			this->packageToolStripMenuItem1->Name = L"packageToolStripMenuItem1";
2266
			this->packageToolStripMenuItem1->Size = System::Drawing::Size(221, 38);
2267
			this->packageToolStripMenuItem1->Text = L"Package";
2268
			this->packageToolStripMenuItem1->Click += gcnew System::EventHandler(this, &Form1::packageToolStripMenuItem1_Click);
2269
			// 
2270
			// shipToolStripMenuItem1
2271
			// 
2272
			this->shipToolStripMenuItem1->Name = L"shipToolStripMenuItem1";
2273
			this->shipToolStripMenuItem1->Size = System::Drawing::Size(221, 38);
2274
			this->shipToolStripMenuItem1->Text = L"Ship";
2275
			this->shipToolStripMenuItem1->Click += gcnew System::EventHandler(this, &Form1::shipToolStripMenuItem1_Click);
2276
			// 
2277
			// multiPackageToolStripMenuItem
2278
			// 
2279
			this->multiPackageToolStripMenuItem->Name = L"multiPackageToolStripMenuItem";
2280
			this->multiPackageToolStripMenuItem->Size = System::Drawing::Size(221, 38);
2281
			this->multiPackageToolStripMenuItem->Text = L"Multi Package";
2282
			this->multiPackageToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::multiPackageToolStripMenuItem_Click);
2283
			// 
2284
			// toolStripSeparator4
2285
			// 
2286
			this->toolStripSeparator4->Name = L"toolStripSeparator4";
2287
			this->toolStripSeparator4->Size = System::Drawing::Size(218, 6);
2288
			// 
2289
			// fromPackagerScriptToolStripMenuItem
2290
			// 
2291
			this->fromPackagerScriptToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"fromPackagerScriptToolStripMenuItem.Image")));
2292
			this->fromPackagerScriptToolStripMenuItem->Name = L"fromPackagerScriptToolStripMenuItem";
2293
			this->fromPackagerScriptToolStripMenuItem->Size = System::Drawing::Size(221, 38);
2294
			this->fromPackagerScriptToolStripMenuItem->Text = L"From Packager Script";
2295
			this->fromPackagerScriptToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::fromPackagerScriptToolStripMenuItem_Click);
2296
			// 
2297
			// fromArchiveToolStripMenuItem
2298
			// 
2299
			this->fromArchiveToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"fromArchiveToolStripMenuItem.Image")));
2300
			this->fromArchiveToolStripMenuItem->Name = L"fromArchiveToolStripMenuItem";
2301
			this->fromArchiveToolStripMenuItem->Size = System::Drawing::Size(221, 38);
2302
			this->fromArchiveToolStripMenuItem->Text = L"From Archive";
2303
			this->fromArchiveToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::fromArchiveToolStripMenuItem_Click);
2304
			// 
2305
			// importShipFromModToolStripMenuItem
2306
			// 
2307
			this->importShipFromModToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"importShipFromModToolStripMenuItem.Image")));
2308
			this->importShipFromModToolStripMenuItem->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
2309
			this->importShipFromModToolStripMenuItem->Name = L"importShipFromModToolStripMenuItem";
2310
			this->importShipFromModToolStripMenuItem->Size = System::Drawing::Size(221, 38);
2311
			this->importShipFromModToolStripMenuItem->Text = L"Import Ship From Mod";
2312
			this->importShipFromModToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::importShipFromModToolStripMenuItem_Click);
2313
			// 
2314
			// toolStripSeparator7
2315
			// 
2316
			this->toolStripSeparator7->Name = L"toolStripSeparator7";
2317
			this->toolStripSeparator7->Size = System::Drawing::Size(218, 6);
2318
			// 
2319
			// packageCreationWizardToolStripMenuItem1
2320
			// 
2321
			this->packageCreationWizardToolStripMenuItem1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"packageCreationWizardToolStripMenuItem1.Image")));
2322
			this->packageCreationWizardToolStripMenuItem1->ImageScaling = System::Windows::Forms::ToolStripItemImageScaling::None;
2323
			this->packageCreationWizardToolStripMenuItem1->Name = L"packageCreationWizardToolStripMenuItem1";
2324
			this->packageCreationWizardToolStripMenuItem1->Size = System::Drawing::Size(221, 38);
2325
			this->packageCreationWizardToolStripMenuItem1->Text = L"Package Creation Wizard";
2326
			this->packageCreationWizardToolStripMenuItem1->Click += gcnew System::EventHandler(this, &Form1::packageCreationWizardToolStripMenuItem1_Click);
2327
			// 
2328
			// toolStripSplitButton1
2329
			// 
2330
			this->toolStripSplitButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripSplitButton1.Image")));
2331
			this->toolStripSplitButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
2332
			this->toolStripSplitButton1->Name = L"toolStripSplitButton1";
2333
			this->toolStripSplitButton1->RightToLeft = System::Windows::Forms::RightToLeft::No;
2334
			this->toolStripSplitButton1->Size = System::Drawing::Size(84, 36);
2335
			this->toolStripSplitButton1->Text = L"Open";
2336
			this->toolStripSplitButton1->ToolTipText = L"Open an existing package/ship";
2337
			this->toolStripSplitButton1->ButtonClick += gcnew System::EventHandler(this, &Form1::toolStripSplitButton1_ButtonClick);
2338
			// 
2339
			// toolStripSeparator3
2340
			// 
2341
			this->toolStripSeparator3->Name = L"toolStripSeparator3";
2342
			this->toolStripSeparator3->Size = System::Drawing::Size(6, 39);
2343
			// 
2344
			// toolStripButton2
2345
			// 
2346
			this->toolStripButton2->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image;
2347
			this->toolStripButton2->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripButton2.Image")));
2348
			this->toolStripButton2->ImageTransparentColor = System::Drawing::Color::Magenta;
2349
			this->toolStripButton2->Name = L"toolStripButton2";
2350
			this->toolStripButton2->Size = System::Drawing::Size(36, 36);
2351
			this->toolStripButton2->Text = L"toolStripButton2";
2352
			this->toolStripButton2->ToolTipText = L"Open the options menu";
2353
			this->toolStripButton2->Click += gcnew System::EventHandler(this, &Form1::toolStripButton2_Click);
2354
			// 
2355
			// toolStripSeparator8
2356
			// 
2357
			this->toolStripSeparator8->Name = L"toolStripSeparator8";
2358
			this->toolStripSeparator8->Size = System::Drawing::Size(6, 39);
2359
			// 
2360
			// toolStripDropDownButton1
2361
			// 
2362
			this->toolStripDropDownButton1->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(7) {this->modMergeToolStripMenuItem1, 
2363
				this->modDiffToolStripMenuItem, this->toolStripSeparator9, this->generatePackageWebListToolStripMenuItem, this->generatePackageUpdatesToolStripMenuItem, 
2364
				this->toolStripSeparator11, this->fileExplorerToolStripMenuItem});
2365
			this->toolStripDropDownButton1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"toolStripDropDownButton1.Image")));
2366
			this->toolStripDropDownButton1->ImageTransparentColor = System::Drawing::Color::Magenta;
2367
			this->toolStripDropDownButton1->Name = L"toolStripDropDownButton1";
2368
			this->toolStripDropDownButton1->Size = System::Drawing::Size(81, 36);
2369
			this->toolStripDropDownButton1->Text = L"Tools";
2370
			// 
2371
			// modMergeToolStripMenuItem1
2372
			// 
2373
			this->modMergeToolStripMenuItem1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"modMergeToolStripMenuItem1.Image")));
2374
			this->modMergeToolStripMenuItem1->Name = L"modMergeToolStripMenuItem1";
2375
			this->modMergeToolStripMenuItem1->Size = System::Drawing::Size(216, 22);
2376
			this->modMergeToolStripMenuItem1->Text = L"Mod Merge";
2377
			this->modMergeToolStripMenuItem1->Click += gcnew System::EventHandler(this, &Form1::modMergeToolStripMenuItem1_Click);
2378
			// 
2379
			// modDiffToolStripMenuItem
2380
			// 
2381
			this->modDiffToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"modDiffToolStripMenuItem.Image")));
2382
			this->modDiffToolStripMenuItem->Name = L"modDiffToolStripMenuItem";
2383
			this->modDiffToolStripMenuItem->Size = System::Drawing::Size(216, 22);
2384
			this->modDiffToolStripMenuItem->Text = L"Mod Diff";
2385
			this->modDiffToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::modDiffToolStripMenuItem_Click);
2386
			// 
2387
			// toolStripSeparator9
2388
			// 
2389
			this->toolStripSeparator9->Name = L"toolStripSeparator9";
2390
			this->toolStripSeparator9->Size = System::Drawing::Size(213, 6);
2391
			// 
2392
			// generatePackageWebListToolStripMenuItem
2393
			// 
2394
			this->generatePackageWebListToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"generatePackageWebListToolStripMenuItem.Image")));
2395
			this->generatePackageWebListToolStripMenuItem->Name = L"generatePackageWebListToolStripMenuItem";
2396
			this->generatePackageWebListToolStripMenuItem->Size = System::Drawing::Size(216, 22);
2397
			this->generatePackageWebListToolStripMenuItem->Text = L"Generate Package Web List";
2398
			this->generatePackageWebListToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::generatePackageWebListToolStripMenuItem_Click);
2399
			// 
2400
			// generatePackageUpdatesToolStripMenuItem
2401
			// 
2402
			this->generatePackageUpdatesToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"generatePackageUpdatesToolStripMenuItem.Image")));
2403
			this->generatePackageUpdatesToolStripMenuItem->Name = L"generatePackageUpdatesToolStripMenuItem";
2404
			this->generatePackageUpdatesToolStripMenuItem->Size = System::Drawing::Size(216, 22);
2405
			this->generatePackageUpdatesToolStripMenuItem->Text = L"Generate Package Updates";
2406
			this->generatePackageUpdatesToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::generatePackageUpdatesToolStripMenuItem_Click);
2407
			// 
2408
			// toolStripSeparator11
2409
			// 
2410
			this->toolStripSeparator11->Name = L"toolStripSeparator11";
2411
			this->toolStripSeparator11->Size = System::Drawing::Size(213, 6);
2412
			// 
2413
			// fileExplorerToolStripMenuItem
2414
			// 
2415
			this->fileExplorerToolStripMenuItem->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"fileExplorerToolStripMenuItem.Image")));
2416
			this->fileExplorerToolStripMenuItem->Name = L"fileExplorerToolStripMenuItem";
2417
			this->fileExplorerToolStripMenuItem->Size = System::Drawing::Size(216, 22);
2418
			this->fileExplorerToolStripMenuItem->Text = L"File Explorer";
2419
			this->fileExplorerToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::fileExplorerToolStripMenuItem_Click);
2420
			// 
2421
			// timer1
2422
			// 
2423
			this->timer1->Enabled = true;
2424
			this->timer1->Interval = 500;
2425
			this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
2426
			// 
2427
			// statusStrip1
2428
			// 
2429
			this->statusStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->StatusFiles});
2430
			this->statusStrip1->Location = System::Drawing::Point(0, 674);
2431
			this->statusStrip1->Name = L"statusStrip1";
2432
			this->statusStrip1->Size = System::Drawing::Size(747, 22);
2433
			this->statusStrip1->TabIndex = 9;
2434
			this->statusStrip1->Text = L"statusStrip1";
2435
			// 
2436
			// StatusFiles
2437
			// 
2438
			this->StatusFiles->Name = L"StatusFiles";
2439
			this->StatusFiles->Size = System::Drawing::Size(79, 17);
2440
			this->StatusFiles->Text = L"Files: 1 (10KB)";
2441
			// 
2442
			// imageListGames
2443
			// 
2444
			this->imageListGames->ImageStream = (cli::safe_cast<System::Windows::Forms::ImageListStreamer^  >(resources->GetObject(L"imageListGames.ImageStream")));
2445
			this->imageListGames->TransparentColor = System::Drawing::Color::Transparent;
2446
			this->imageListGames->Images->SetKeyName(0, L"X2");
2447
			this->imageListGames->Images->SetKeyName(1, L"X3");
2448
			this->imageListGames->Images->SetKeyName(2, L"X3TC");
2449
			this->imageListGames->Images->SetKeyName(3, L"X3AP");
2450
			// 
2451
			// toolTip1
2452
			// 
2453
			this->toolTip1->AutomaticDelay = 1000;
2454
			this->toolTip1->IsBalloon = true;
2455
			this->toolTip1->ToolTipIcon = System::Windows::Forms::ToolTipIcon::Info;
2456
			this->toolTip1->ToolTipTitle = L"Close All Windows";
2457
			// 
2458
			// imageListSmall
2459
			// 
2460
			this->imageListSmall->ImageStream = (cli::safe_cast<System::Windows::Forms::ImageListStreamer^  >(resources->GetObject(L"imageListSmall.ImageStream")));
2461
			this->imageListSmall->TransparentColor = System::Drawing::Color::Transparent;
2462
			this->imageListSmall->Images->SetKeyName(0, L"language");
2463
			this->imageListSmall->Images->SetKeyName(1, L"web");
2464
			this->imageListSmall->Images->SetKeyName(2, L"ware");
2465
			this->imageListSmall->Images->SetKeyName(3, L"components");
2466
			this->imageListSmall->Images->SetKeyName(4, L"dummies");
2467
			this->imageListSmall->Images->SetKeyName(5, L"cockpit");
2468
			this->imageListSmall->Images->SetKeyName(6, L"cutdata");
2469
			this->imageListSmall->Images->SetKeyName(7, L"bodies");
2470
			this->imageListSmall->Images->SetKeyName(8, L"animations");
2471
			this->imageListSmall->Images->SetKeyName(9, L"turret");
2472
			this->imageListSmall->Images->SetKeyName(10, L"gun");
2473
			// 
2474
			// imageListLarge
2475
			// 
2476
			this->imageListLarge->ImageStream = (cli::safe_cast<System::Windows::Forms::ImageListStreamer^  >(resources->GetObject(L"imageListLarge.ImageStream")));
2477
			this->imageListLarge->TransparentColor = System::Drawing::Color::Transparent;
2478
			this->imageListLarge->Images->SetKeyName(0, L"language");
2479
			this->imageListLarge->Images->SetKeyName(1, L"web");
2480
			this->imageListLarge->Images->SetKeyName(2, L"ware");
2481
			this->imageListLarge->Images->SetKeyName(3, L"turret");
2482
			this->imageListLarge->Images->SetKeyName(4, L"gun");
2483
			// 
2484
			// imageListFiles
2485
			// 
2486
			this->imageListFiles->ImageStream = (cli::safe_cast<System::Windows::Forms::ImageListStreamer^  >(resources->GetObject(L"imageListFiles.ImageStream")));
2487
			this->imageListFiles->TransparentColor = System::Drawing::Color::Transparent;
2488
			this->imageListFiles->Images->SetKeyName(0, L"script.png");
2489
			this->imageListFiles->Images->SetKeyName(1, L"textfile.png");
2490
			this->imageListFiles->Images->SetKeyName(2, L"readme.png");
2491
			this->imageListFiles->Images->SetKeyName(3, L"map.png");
2492
			this->imageListFiles->Images->SetKeyName(4, L"mods.png");
2493
			this->imageListFiles->Images->SetKeyName(5, L"uninstall.png");
2494
			this->imageListFiles->Images->SetKeyName(6, L"sound.png");
2495
			this->imageListFiles->Images->SetKeyName(7, L"extras.png");
2496
			this->imageListFiles->Images->SetKeyName(8, L"screenshot.png");
2497
			this->imageListFiles->Images->SetKeyName(9, L"mission.png");
2498
			this->imageListFiles->Images->SetKeyName(10, L"advert.png");
2499
			this->imageListFiles->Images->SetKeyName(11, L"shipother.png");
2500
			this->imageListFiles->Images->SetKeyName(12, L"shipmodel.png");
2501
			this->imageListFiles->Images->SetKeyName(13, L"shipscene.png");
2502
			this->imageListFiles->Images->SetKeyName(14, L"cockpitscene.png");
2503
			this->imageListFiles->Images->SetKeyName(15, L"package");
2504
			this->imageListFiles->Images->SetKeyName(16, L"backup.png");
2505
			this->imageListFiles->Images->SetKeyName(17, L"fakepatch");
2506
			// 
2507
			// backgroundWorker1
2508
			// 
2509
			this->backgroundWorker1->WorkerReportsProgress = true;
2510
			this->backgroundWorker1->WorkerSupportsCancellation = true;
2511
			this->backgroundWorker1->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &Form1::backgroundWorker1_DoWork);
2512
			this->backgroundWorker1->RunWorkerCompleted += gcnew System::ComponentModel::RunWorkerCompletedEventHandler(this, &Form1::backgroundWorker1_RunWorkerCompleted);
2513
			// 
2514
			// Form1
2515
			// 
2516
			this->AllowDrop = true;
2517
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
2518
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
2519
			this->ClientSize = System::Drawing::Size(747, 696);
2520
			this->Controls->Add(this->statusStrip1);
2521
			this->Controls->Add(this->PanelTab);
2522
			this->Controls->Add(this->toolStrip1);
2523
			this->Controls->Add(this->menuStrip1);
2524
			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
2525
			this->IsMdiContainer = true;
2526
			this->MainMenuStrip = this->menuStrip1;
2527
			this->Name = L"Form1";
2528
			this->Text = L"Package Creator";
2529
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
2530
			this->DragDrop += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::Form1_DragDrop);
2531
			this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &Form1::Form1_FormClosing);
2532
			this->DragOver += gcnew System::Windows::Forms::DragEventHandler(this, &Form1::Form1_DragOver);
2533
			this->menuStrip1->ResumeLayout(false);
2534
			this->menuStrip1->PerformLayout();
2535
			this->PanelTab->ResumeLayout(false);
2536
			this->toolStrip1->ResumeLayout(false);
2537
			this->toolStrip1->PerformLayout();
2538
			this->statusStrip1->ResumeLayout(false);
2539
			this->statusStrip1->PerformLayout();
2540
			this->ResumeLayout(false);
2541
			this->PerformLayout();
2542
 
2543
		}
2544
#pragma endregion
2545
	private: System::Void cascadeToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2546
				 this->LayoutMdi(MdiLayout::Cascade);
2547
			 }
2548
private: System::Void horizontalToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2549
			 this->LayoutMdi(MdiLayout::TileHorizontal);
2550
		 }
2551
private: System::Void verticalToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2552
			 this->LayoutMdi(MdiLayout::TileVertical);
2553
		 }
2554
private: System::Void tabControl1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
2555
			 cli::array<System::Windows::Forms::Form ^> ^children = this->MdiChildren;
2556
			 for ( int i = 0; i < children->Length; i++ )
2557
			 {
2558
				 BaseForm ^childForm = (BaseForm ^)children[i];
2559
				 if ( childForm->TabPage()->Equals(tabControl1->SelectedTab) )
2560
				 {
2561
					 childForm->Select();
2562
					 break;
2563
				 }
2564
			 }
2565
 
2566
		 }
2567
private: System::Void packageToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2568
			 this->NewPackage(false);
2569
		 }
2570
private: System::Void shipToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2571
			 this->NewPackage(true);
2572
		 }
2573
private: System::Void exitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2574
			 this->Close();
2575
		 }
2576
private: System::Void saveToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2577
			 this->Save();
2578
		 }
2579
private: System::Void saveAsToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2580
			 this->SaveAs();
2581
		 }
2582
private: System::Void Event_Open(System::Object^  sender, System::EventArgs^  e) {
2583
			System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
2584
			if ( item->Tag == "$PACKAGE" )
2585
				this->Open();
2586
			else if ( item->Tag == "$DIR" )
2587
			{
2588
				FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
2589
				fbd->Description = "Select the path to load all valid files from";
2590
				if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
2591
					this->OpenDirectory(fbd->SelectedPath);
2592
			}
2593
			else
2594
			{
2595
				this->Open(cli::safe_cast<System::String ^>(item->Tag), true, false);
2596
			}
2597
		}
2598
 
2599
private: System::Void openPackageToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2600
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
2601
			ofd->Filter = "All (*.spk *.xsp)|*.spk;*.xsp|Package Files (*.spk)|*.spk|Ship Files (*.xsp)|*.xsp";
2602
			ofd->FilterIndex = 1;
2603
			ofd->RestoreDirectory = true;
2604
			ofd->Multiselect = true;
2605
 
2606
			if ( ofd->ShowDialog() == System::Windows::Forms::DialogResult::OK )
2607
				this->OpenFiles(ofd->FileNames, false, true);
2608
		 }
2609
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
2610
				 this->CloseAll();
2611
			 }
2612
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
2613
			 if ( m_bAutoClose )
2614
				 this->Close();
2615
			 if ( m_iLocX != -1 && m_iLocY != -1 )
2616
				this->Location = System::Drawing::Point(m_iLocX, m_iLocY);
2617
			this->UpdateDropDownOpen();
2618
		 }
2619
private: System::Void toolStripSplitButton1_ButtonClick(System::Object^  sender, System::EventArgs^  e) {
2620
			 this->Open();
2621
		 }
2622
private: System::Void packageToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {
2623
			 this->NewPackage(false);
2624
		 }
2625
private: System::Void shipToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {
2626
			 this->NewPackage(true);
2627
		 }
2628
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
2629
			 if ( IO::File::Exists(IO::Path::GetTempPath() + "\\creator_load.dat") )
2630
				 this->LoadFiles(IO::Path::GetTempPath() + "\\creator_load.dat");
2631
		 }
2632
private: System::Void tabControl1_SelectedIndexChanged_1(System::Object^  sender, System::EventArgs^  e) {
2633
			 cli::array<System::Windows::Forms::Form ^> ^children = this->MdiChildren;
2634
			 for ( int i = 0; i < children->Length; i++ )
2635
			 {
2636
				 BaseForm ^childForm = (BaseForm ^)children[i];
2637
				 if ( childForm->TabPage()->Equals(tabControl1->SelectedTab) )
2638
				 {
2639
					 childForm->Select();
2640
					 break;
2641
				 }
2642
			 }
2643
		 }
2644
private: System::Void configToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2645
			 this->OpenOptionsMenu();
2646
		 }
2647
private: System::Void toolStripButton2_Click(System::Object^  sender, System::EventArgs^  e) {
2648
			 this->OpenOptionsMenu();
2649
		 }
2650
private: System::Void fromPackagerScriptToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {
2651
			 this->OpenPackagerScript();
2652
		 }
2653
private: System::Void fromPackagerScriptToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2654
			 this->OpenPackagerScript();
2655
		 }
2656
private: System::Void Form1_DragOver(System::Object^  sender, System::Windows::Forms::DragEventArgs^  e) {
2657
			e->Effect = DragDropEffects::None;
2658
 
2659
			if (e->Data->GetDataPresent(DataFormats::FileDrop)) 
2660
			{
2661
				cli::array<String ^> ^a = (cli::array<String ^> ^)e->Data->GetData(DataFormats::FileDrop, false);
2662
				int i;
2663
				for(i = 0; i < a->Length; i++)
2664
				{
2665
					if ( String::Compare(IO::FileInfo(a[i]).Extension, ".xsp", true) == 0 || String::Compare(IO::FileInfo(a[i]).Extension, ".spk", true) == 0 )
2666
					{
2667
						e->Effect = DragDropEffects::Copy;
2668
						break;
2669
					}
2670
				}
2671
			}
2672
		 }
2673
private: System::Void Form1_DragDrop(System::Object^  sender, System::Windows::Forms::DragEventArgs^  e) {
2674
			if (e->Data->GetDataPresent(DataFormats::FileDrop)) 
2675
			{
2676
				cli::array<String ^> ^a = (cli::array<String ^> ^)e->Data->GetData(DataFormats::FileDrop, false);
2677
				this->OpenFiles(a, true, true);
2678
			}
2679
		 }
2680
private: System::Void importShipFromModToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {
2681
			 this->ImportShip();
2682
		 }
2683
private: System::Void importShipFromModToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2684
			 this->ImportShip();
2685
		 }
2686
private: System::Void Form1_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
2687
			 this->CloseAll();
2688
			 e->Cancel = false;
2689
		 }
2690
private: System::Void packageCreationWizardToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2691
			 this->PackageCreationWizard();
2692
		 }
2693
private: System::Void packageCreationWizardToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {
2694
			 this->PackageCreationWizard();
2695
		 }
2696
private: System::Void multiPackageToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2697
			 this->NewMultiPackage();
2698
		 }
2699
private: System::Void modMergeToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {
2700
			 ModMerge();
2701
		 }
2702
private: System::Void modMergeToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2703
			 ModMerge();
2704
		 }
2705
private: System::Void modDiffToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {
2706
			 ModDiffDialog();
2707
		 }
2708
private: System::Void modDiffToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2709
			 ModDiffDialog();
2710
		 }
2711
private: System::Void generatePackageWebListToolStripMenuItem1_Click(System::Object^  sender, System::EventArgs^  e) {
2712
			 GeneratePackageWebList();
2713
		 }
2714
private: System::Void generatePackageWebListToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2715
			 GeneratePackageWebList();
2716
		 }
2717
private: System::Void fromArchiveToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2718
			 OpenArchive();
2719
		 }
2720
private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
2721
			 Threading::Thread::Sleep(500);
2722
			 m_pConverted = m_pPackages->CreateFromArchive(CyStringFromSystemString(m_sConvertFile));
2723
		 }
2724
private: System::Void backgroundWorker1_RunWorkerCompleted(System::Object^  sender, System::ComponentModel::RunWorkerCompletedEventArgs^  e) {
2725
			 if ( m_pWait ) 
2726
			 {
2727
				 m_pWait->Close();
2728
				 delete m_pWait;
2729
				 m_pWait = nullptr;
2730
			}
2731
 
2732
			 if ( !m_pConverted )
2733
				MessageBox::Show(this, "Unable to open archive file, " + m_sConvertFile, "Unable to open", MessageBoxButtons::OK, MessageBoxIcon::Error);
2734
			 else
2735
			 {
2736
				PackageForm ^childForm = this->OpenPackage(true, m_pConverted, m_sConvertFile, "");
2737
				childForm->Text = SystemStringFromCyString(m_pConverted->GetFilename());
2738
			 }
2739
		 }
2740
private: System::Void generatePackageUpdatesToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2741
			 GeneratePackageUpdates();
2742
		 }
2743
private: System::Void fileExplorerToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
2744
			 OpenFileExplorer();
2745
		 }
2746
};
2747
}
2748