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