Subversion Repositories spk

Rev

Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 cycrow 1
#pragma once
2
 
3
 
4
namespace ModMerge {
5
 
6
	using namespace System;
7
	using namespace System::ComponentModel;
8
	using namespace System::Collections;
9
	using namespace System::Windows::Forms;
10
	using namespace System::Data;
11
	using namespace System::Drawing;
12
 
13
	/// <summary>
14
	/// Summary for Form1
15
	///
16
	/// WARNING: If you change the name of this class, you will need to change the
17
	///          'Resource File Name' property for the managed resource compiler tool
18
	///          associated with all .resx files this class depends on.  Otherwise,
19
	///          the designers will not be able to interact properly with localized
20
	///          resources associated with this form.
21
	/// </summary>
22
	public ref class Form1 : public System::Windows::Forms::Form
23
	{
24
	public:
25
		Form1(void)
26
		{
27
			InitializeComponent();
28
 
29
			m_pFile1 = new CCatFile;
30
			m_pFile2 = new CCatFile;
31
 
32
			this->panel1->Enabled = false;
33
			this->panel2->Enabled = false;
34
			this->panel5->Enabled = false;
35
 
36
			m_pPackages = new CPackages();
37
			m_pPackages->Startup(".", ".", ".");
38
 
39
			m_iLocX = m_iLocY = -1;
40
		}
41
 
42
		String ^OpenFile(String ^desc)
43
		{
44
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
45
			ofd->Filter = "X-Mod Files (*.cat)|*.cat";
46
			ofd->FilterIndex = 1;
47
			ofd->RestoreDirectory = true;
48
			ofd->Title = desc;
49
			if ( ofd->ShowDialog(this) == Windows::Forms::DialogResult::OK )
50
				return ofd->FileName;
51
			return nullptr;
52
		}
53
 
54
		void UpdateFileList()
55
		{
56
			Windows::Forms::Cursor::Current = Windows::Forms::Cursors::WaitCursor;
57
			this->treeView1->BeginUpdate();
58
			this->treeView1->Nodes->Clear();
59
			CyStringList *list = m_pPackages->GetMergedFiles(m_pFile1, m_pFile2);
60
			if ( list )
61
			{
62
				TreeNode ^merged = gcnew TreeNode("Files to Merge");
63
				TreeNode ^conflict = gcnew TreeNode("Potential Conflicts");
64
				TreeNode ^both = gcnew TreeNode("Files in Both (using primarys)");
65
				TreeNode ^node1 = gcnew TreeNode("From: " + this->textBox1->Text);
66
				TreeNode ^node2 = gcnew TreeNode("From: " + this->textBox2->Text);
67
				this->treeView1->Nodes->Add(merged);
68
				this->treeView1->Nodes->Add(conflict);
69
				this->treeView1->Nodes->Add(both);
70
				this->treeView1->Nodes->Add(node1);
71
				this->treeView1->Nodes->Add(node2);
72
 
73
				merged->ForeColor = Color::Green;
74
				conflict->ForeColor = Color::Red;
75
 
76
				for ( SStringList *str = list->Head(); str; str = str->next )
77
				{
78
					TreeNode ^newNode = gcnew TreeNode(SystemStringFromCyString(str->str));
79
 
80
					int status = str->data.ToInt();
81
					if ( status == -1 ) // in both
82
					{
83
						if ( m_pPackages->CanWeMerge(str->str) )
84
							merged->Nodes->Add(newNode);
85
						else if ( m_pPackages->NeedToMerge(str->str) )
86
							conflict->Nodes->Add(newNode);
87
						else
88
							both->Nodes->Add(newNode);
89
					}
90
					else if ( status == 1 )
91
						node1->Nodes->Add(newNode);
92
					else if ( status == 2 )
93
						node2->Nodes->Add(newNode);
94
				}
95
 
96
				merged->Text = "[" + merged->Nodes->Count + "] " + merged->Text;
97
				node1->Text = "[" + node1->Nodes->Count + "] " + node1->Text;
98
				node2->Text = "[" + node2->Nodes->Count + "] " + node2->Text;
99
				both->Text = "[" + both->Nodes->Count + "] " + both->Text;
100
				conflict->Text = "[" + conflict->Nodes->Count + "] " + conflict->Text;
101
 
102
				this->treeView1->ExpandAll();
103
				this->button4->Enabled = true;
104
			}
105
 
106
			delete list;
107
 
108
			Windows::Forms::Cursor::Current = Cursors::Default;
109
			this->treeView1->EndUpdate();
110
		}
111
 
112
		void DoGameDirectory()
113
		{
114
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
115
			ofd->Title = "Choose the path for the Game you wish to merge mods for";
116
			ofd->Filter = "X-Universe Executable|";
117
			String ^games = "";
118
			for ( int i = 0; i < m_pPackages->GetGameExe()->GetNumGames(); i++ )
119
			{
120
				SGameExe *exe = m_pPackages->GetGameExe()->GetGame(i);
121
				if ( i ) ofd->Filter += ";";
122
				ofd->Filter += SystemStringFromCyString(exe->sExe);
123
				games += "|" + SystemStringFromCyString(exe->sName) + "|" + SystemStringFromCyString(exe->sExe);
124
			}
125
			ofd->Filter += games;
126
			ofd->FilterIndex = 1;
127
			ofd->RestoreDirectory = true;
128
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
129
			{
130
				if (!SetGameDir(-1, IO::FileInfo(ofd->FileName).DirectoryName))
131
					MessageBox::Show(this, "Error: not a valid game directory\n" + IO::FileInfo(ofd->FileName).DirectoryName, "Invalid Game Directory", MessageBoxButtons::OK, MessageBoxIcon::Error);
132
			}
133
		}
134
 
135
		void StartMerge()
136
		{
137
			SaveFileDialog ^ofd = gcnew SaveFileDialog();
138
			ofd->Filter = "X-Universe Mod File (*.cat)|*.cat";
139
			ofd->Title = "Select the mod file you wish to merge files into";
140
			ofd->FilterIndex = 1;
141
			ofd->RestoreDirectory = true;
142
			ofd->AddExtension = true;
143
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
144
				Merge(ofd->FileName);
145
		}
146
 
147
		void Merge(String ^file)
148
		{
149
			// create the mod file by copying the primary mod
150
			if ( IO::File::Exists(file) )
151
				IO::File::Delete(file);
152
			IO::File::Copy(this->textBox1->Text, file);
153
			// and the dat file
154
			CyString file1 = CFileIO(CyStringFromSystemString(this->textBox1->Text)).ChangeFileExtension("dat");
155
			CyString file2 = CFileIO(CyStringFromSystemString(file)).ChangeFileExtension("dat");
156
			if ( IO::File::Exists(SystemStringFromCyString(file2)) )
157
				IO::File::Delete(SystemStringFromCyString(file2));
158
			IO::File::Copy(SystemStringFromCyString(file1), SystemStringFromCyString(file2));
159
 
160
			CCatFile CatFile;
161
			if ( !CCatFile::Opened(CatFile.Open(CyStringFromSystemString(file), "", CATREAD_CATDECRYPT, false), false) )
162
			{
163
				MessageBox::Show(this, "Unable to open cat file: " + file, "Merge Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
164
				return;
165
			}
166
 
167
			// now we need to move non merge files from the 2nd mod to the new one
168
			CyStringList *list = m_pPackages->GetMergedFiles(m_pFile1, m_pFile2);
169
			if ( list )
170
			{
171
				for ( SStringList *str = list->Head(); str; str = str->next )
172
				{
173
					int status = str->data.ToInt();
174
					if ( status == 2 ) // in 2nd mod
175
						CatFile.AppendFile(CyStringFromSystemString(this->textBox2->Text) + "::" + str->str, str->str);
176
					// finally, we need to diff the remaining files
177
					else if ( status == -1 ) // in both
178
					{
179
						// only diffable files, we ignore the rest
180
						if ( CModDiff::CanBeDiffed(str->str) )
181
						{
182
							CModDiff Diff(CyStringFromSystemString(this->textBox3->Text), Convert::ToInt32(this->numericUpDown1->Value));
183
							if ( !Diff.CreateDiff(CyStringFromSystemString(this->textBox2->Text)) )
184
								continue;
185
							Diff.ApplyDiff(CyStringFromSystemString(file));
186
						}
187
					}
188
				}
189
 
190
				delete list;
191
			}
192
 
193
			MessageBox::Show(this, "Mod files have been merged to: " + file, "Mod Merged", MessageBoxButtons::OK, MessageBoxIcon::Information);
194
		}
195
 
196
		void LoadData()
197
		{
198
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
199
			CFileIO Config;
200
			if ( Config.Open(CyStringFromSystemString(mydoc) + "/Egosoft/modmerge.dat") )
201
			{
202
				std::vector<CyString> *lines = Config.ReadLines();
203
				if ( lines )
204
				{
205
					for ( int i = 0; i < (int)lines->size(); i++ )
206
					{
207
						CyString line(lines->at(i));
208
						CyString start = line.GetToken(":", 1, 1).lower();
209
						CyString rest = line.GetToken(":", 2).RemoveFirstSpace();
210
						if ( start.Compare("ModMergeSize") )
211
							this->Size = System::Drawing::Size(rest.GetToken(" ", 1, 1).ToInt(), rest.GetToken(" ", 2, 2).ToInt());
212
						else if ( start.Compare("ModMergePos") )
213
						{
214
							m_iLocX = rest.GetToken(" ", 1, 1).ToInt();
215
							m_iLocY = rest.GetToken(" ", 2, 2).ToInt();
216
							if ( !this->TopMost )
217
								this->Location = System::Drawing::Point(m_iLocX, m_iLocY);
218
						}
219
						else if ( start.Compare("ModMergeMax") )
220
						{
221
							if ( !this->TopMost )
222
								this->WindowState = FormWindowState::Maximized;
223
						}
224
						else if ( start.Compare("GameDir") )
225
							SetGameDir(rest.GetToken(";", 1, 1).ToInt(), SystemStringFromCyString(rest.GetToken(";", 2)));
226
					}
227
 
228
					delete lines;
229
				}
230
			}
231
 
232
			if ( m_pPackages->GetCurrentDirectory().Empty() )
233
				DoGameDirectory();
234
		}
235
 
236
		void SaveData()
237
		{
238
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
239
			CFileIO Config(CyStringFromSystemString(mydoc) + "/Egosoft/modmerge.dat");
240
			CyStringList lines;
241
 
242
			if ( this->WindowState == FormWindowState::Normal )
243
			{
244
				lines.PushBack(CyString("ModMergeSize:") + (long)this->Size.Width + " " + (long)this->Size.Height);
245
				if ( this->TopMost )
246
				{
247
					if ( m_iLocX != -1 && m_iLocY != -1 )
248
						lines.PushBack(CyString("ModMergePos:") + (long)m_iLocX + " " + (long)m_iLocY);
249
				}
250
				else
251
					lines.PushBack(CyString("ModMergePos:") + (long)this->Location.X + " " + (long)this->Location.Y);
252
			}
253
			else
254
			{
255
				lines.PushBack(CyString("ModMergeSize:") + (long)this->RestoreBounds.Size.Width + " " + (long)this->RestoreBounds.Size.Height);
256
				if ( this->TopMost )
257
				{
258
					if ( m_iLocX != -1 && m_iLocY != -1 )
259
						lines.PushBack(CyString("ModMergePos:") + (long)m_iLocX + " " + (long)m_iLocY);
260
				}
261
				else
262
					lines.PushBack(CyString("ModMergePos:") + (long)this->RestoreBounds.Location.X + " " + (long)this->RestoreBounds.Location.Y);
263
			}
264
 
265
			if ( this->WindowState == FormWindowState::Maximized )
266
				lines.PushBack("ModMergeMax:");
267
 
268
			if ( this->textBox3->Text->Length )
269
				lines.PushBack(CyString("GameDir:") + (long)Convert::ToInt32(this->numericUpDown1->Value) + ";" + m_pPackages->GetCurrentDirectory());
270
			Config.WriteFile(&lines);
271
		}
272
 
273
 
274
		bool SetGameDir(int patch, String ^gameDir)
275
		{
276
			CyString dir = CyStringFromSystemString(gameDir);
277
			if ( !dir.Empty() )
278
			{
279
				CyString gameName = m_pPackages->GetGameName(dir);
280
				if ( !gameName.Empty() )
281
				{
282
					this->textBox3->Text = gameDir + " (" + SystemStringFromCyString(gameName) + ")";
283
					this->panel5->Enabled = true;
284
					this->numericUpDown1->Minimum = 1;
285
					m_pPackages->SetCurrentDir(dir);
286
					this->numericUpDown1->Maximum = m_pPackages->FindNextFakePatch() - 1;
287
					if ( patch < 1 || patch > this->numericUpDown1->Maximum )
288
						this->numericUpDown1->Value = this->numericUpDown1->Maximum;
289
					else
290
						this->numericUpDown1->Value = patch;
291
					this->label5->Text = "(prevent loading added mods, max=" + Convert::ToString(this->numericUpDown1->Maximum) + ")";
292
					this->panel1->Enabled = true;
293
 
294
					return true;
295
				}
296
			}
297
 
298
			return false;
299
		}
300
 
301
	protected:
302
		/// <summary>
303
		/// Clean up any resources being used.
304
		/// </summary>
305
		~Form1()
306
		{
307
			if (components)
308
			{
309
				delete components;
310
			}
311
			if ( m_pPackages ) delete m_pPackages;
312
		}
313
 
314
#pragma region defines
315
	private:
316
		CCatFile	*m_pFile1;
317
		CCatFile	*m_pFile2;
318
		CPackages	*m_pPackages;
319
		int			m_iLocX;
320
		int			m_iLocY;
321
#pragma endregion
322
 
323
#pragma region designer defines
324
	private: System::Windows::Forms::Panel^  panel1;
325
	private: System::Windows::Forms::TextBox^  textBox1;
326
	private: System::Windows::Forms::Label^  label1;
327
	private: System::Windows::Forms::Button^  button1;
328
	private: System::Windows::Forms::Panel^  panel2;
329
	private: System::Windows::Forms::TextBox^  textBox2;
330
	private: System::Windows::Forms::Label^  label2;
331
	private: System::Windows::Forms::Button^  button2;
332
	private: System::Windows::Forms::TreeView^  treeView1;
333
private: System::Windows::Forms::Panel^  panel3;
334
private: System::Windows::Forms::Panel^  panel5;
335
private: System::Windows::Forms::Panel^  panel4;
336
private: System::Windows::Forms::NumericUpDown^  numericUpDown1;
337
private: System::Windows::Forms::Label^  label4;
338
private: System::Windows::Forms::TextBox^  textBox3;
339
private: System::Windows::Forms::Label^  label3;
340
private: System::Windows::Forms::Button^  button3;
341
private: System::Windows::Forms::Label^  label5;
342
private: System::Windows::Forms::Panel^  panel6;
343
private: System::Windows::Forms::Button^  button5;
344
private: System::Windows::Forms::Button^  button4;
345
		 /// <summary>
346
		/// Required designer variable.
347
		/// </summary>
348
		System::ComponentModel::Container ^components;
349
#pragma endregion
350
#pragma region Windows Form Designer generated code
351
		/// <summary>
352
		/// Required method for Designer support - do not modify
353
		/// the contents of this method with the code editor.
354
		/// </summary>
355
		void InitializeComponent(void)
356
		{
357
			this->panel1 = (gcnew System::Windows::Forms::Panel());
358
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
359
			this->label1 = (gcnew System::Windows::Forms::Label());
360
			this->button1 = (gcnew System::Windows::Forms::Button());
361
			this->panel2 = (gcnew System::Windows::Forms::Panel());
362
			this->textBox2 = (gcnew System::Windows::Forms::TextBox());
363
			this->label2 = (gcnew System::Windows::Forms::Label());
364
			this->button2 = (gcnew System::Windows::Forms::Button());
365
			this->treeView1 = (gcnew System::Windows::Forms::TreeView());
366
			this->panel3 = (gcnew System::Windows::Forms::Panel());
367
			this->panel5 = (gcnew System::Windows::Forms::Panel());
368
			this->panel4 = (gcnew System::Windows::Forms::Panel());
369
			this->label5 = (gcnew System::Windows::Forms::Label());
370
			this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
371
			this->label4 = (gcnew System::Windows::Forms::Label());
372
			this->textBox3 = (gcnew System::Windows::Forms::TextBox());
373
			this->label3 = (gcnew System::Windows::Forms::Label());
374
			this->button3 = (gcnew System::Windows::Forms::Button());
375
			this->panel6 = (gcnew System::Windows::Forms::Panel());
376
			this->button5 = (gcnew System::Windows::Forms::Button());
377
			this->button4 = (gcnew System::Windows::Forms::Button());
378
			this->panel1->SuspendLayout();
379
			this->panel2->SuspendLayout();
380
			this->panel3->SuspendLayout();
381
			this->panel5->SuspendLayout();
382
			this->panel4->SuspendLayout();
383
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->BeginInit();
384
			this->panel6->SuspendLayout();
385
			this->SuspendLayout();
386
			// 
387
			// panel1
388
			// 
389
			this->panel1->Controls->Add(this->textBox1);
390
			this->panel1->Controls->Add(this->label1);
391
			this->panel1->Controls->Add(this->button1);
392
			this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
393
			this->panel1->Location = System::Drawing::Point(0, 50);
394
			this->panel1->Name = L"panel1";
395
			this->panel1->Padding = System::Windows::Forms::Padding(5);
396
			this->panel1->Size = System::Drawing::Size(564, 31);
397
			this->panel1->TabIndex = 5;
398
			// 
399
			// textBox1
400
			// 
401
			this->textBox1->Dock = System::Windows::Forms::DockStyle::Fill;
402
			this->textBox1->Location = System::Drawing::Point(160, 5);
403
			this->textBox1->Name = L"textBox1";
404
			this->textBox1->ReadOnly = true;
405
			this->textBox1->Size = System::Drawing::Size(371, 20);
406
			this->textBox1->TabIndex = 0;
407
			// 
408
			// label1
409
			// 
410
			this->label1->Dock = System::Windows::Forms::DockStyle::Left;
411
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
412
				static_cast<System::Byte>(0)));
413
			this->label1->Location = System::Drawing::Point(5, 5);
414
			this->label1->Name = L"label1";
415
			this->label1->Size = System::Drawing::Size(155, 21);
416
			this->label1->TabIndex = 2;
417
			this->label1->Text = L"Primary Mod";
418
			this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
419
			// 
420
			// button1
421
			// 
422
			this->button1->AutoSize = true;
423
			this->button1->Dock = System::Windows::Forms::DockStyle::Right;
424
			this->button1->Location = System::Drawing::Point(531, 5);
425
			this->button1->Name = L"button1";
426
			this->button1->Size = System::Drawing::Size(28, 21);
427
			this->button1->TabIndex = 1;
428
			this->button1->Text = L"...";
429
			this->button1->UseVisualStyleBackColor = true;
430
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
431
			// 
432
			// panel2
433
			// 
434
			this->panel2->Controls->Add(this->textBox2);
435
			this->panel2->Controls->Add(this->label2);
436
			this->panel2->Controls->Add(this->button2);
437
			this->panel2->Dock = System::Windows::Forms::DockStyle::Top;
438
			this->panel2->Enabled = false;
439
			this->panel2->Location = System::Drawing::Point(0, 81);
440
			this->panel2->Name = L"panel2";
441
			this->panel2->Padding = System::Windows::Forms::Padding(5);
442
			this->panel2->Size = System::Drawing::Size(564, 31);
443
			this->panel2->TabIndex = 6;
444
			// 
445
			// textBox2
446
			// 
447
			this->textBox2->Dock = System::Windows::Forms::DockStyle::Fill;
448
			this->textBox2->Location = System::Drawing::Point(160, 5);
449
			this->textBox2->Name = L"textBox2";
450
			this->textBox2->ReadOnly = true;
451
			this->textBox2->Size = System::Drawing::Size(371, 20);
452
			this->textBox2->TabIndex = 0;
453
			// 
454
			// label2
455
			// 
456
			this->label2->Dock = System::Windows::Forms::DockStyle::Left;
457
			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
458
				static_cast<System::Byte>(0)));
459
			this->label2->Location = System::Drawing::Point(5, 5);
460
			this->label2->Name = L"label2";
461
			this->label2->Size = System::Drawing::Size(155, 21);
462
			this->label2->TabIndex = 2;
463
			this->label2->Text = L"Secondary Mod";
464
			this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
465
			// 
466
			// button2
467
			// 
468
			this->button2->AutoSize = true;
469
			this->button2->Dock = System::Windows::Forms::DockStyle::Right;
470
			this->button2->Location = System::Drawing::Point(531, 5);
471
			this->button2->Name = L"button2";
472
			this->button2->Size = System::Drawing::Size(28, 21);
473
			this->button2->TabIndex = 1;
474
			this->button2->Text = L"...";
475
			this->button2->UseVisualStyleBackColor = true;
476
			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
477
			// 
478
			// treeView1
479
			// 
480
			this->treeView1->Dock = System::Windows::Forms::DockStyle::Fill;
481
			this->treeView1->Location = System::Drawing::Point(0, 112);
482
			this->treeView1->Name = L"treeView1";
483
			this->treeView1->Size = System::Drawing::Size(564, 395);
484
			this->treeView1->TabIndex = 7;
485
			// 
486
			// panel3
487
			// 
488
			this->panel3->Controls->Add(this->panel5);
489
			this->panel3->Controls->Add(this->label3);
490
			this->panel3->Controls->Add(this->button3);
491
			this->panel3->Dock = System::Windows::Forms::DockStyle::Top;
492
			this->panel3->Location = System::Drawing::Point(0, 0);
493
			this->panel3->Name = L"panel3";
494
			this->panel3->Padding = System::Windows::Forms::Padding(5);
495
			this->panel3->Size = System::Drawing::Size(564, 50);
496
			this->panel3->TabIndex = 8;
497
			// 
498
			// panel5
499
			// 
500
			this->panel5->Controls->Add(this->panel4);
501
			this->panel5->Controls->Add(this->textBox3);
502
			this->panel5->Dock = System::Windows::Forms::DockStyle::Fill;
503
			this->panel5->Location = System::Drawing::Point(160, 5);
504
			this->panel5->Name = L"panel5";
505
			this->panel5->Size = System::Drawing::Size(371, 40);
506
			this->panel5->TabIndex = 6;
507
			// 
508
			// panel4
509
			// 
510
			this->panel4->Controls->Add(this->label5);
511
			this->panel4->Controls->Add(this->numericUpDown1);
512
			this->panel4->Controls->Add(this->label4);
513
			this->panel4->Dock = System::Windows::Forms::DockStyle::Fill;
514
			this->panel4->Location = System::Drawing::Point(0, 20);
515
			this->panel4->Name = L"panel4";
516
			this->panel4->Size = System::Drawing::Size(371, 20);
517
			this->panel4->TabIndex = 5;
518
			// 
519
			// label5
520
			// 
521
			this->label5->Dock = System::Windows::Forms::DockStyle::Fill;
522
			this->label5->Location = System::Drawing::Point(173, 0);
523
			this->label5->Name = L"label5";
524
			this->label5->Size = System::Drawing::Size(198, 20);
525
			this->label5->TabIndex = 5;
526
			this->label5->Text = L"(prevent loading added mods, max=)";
527
			this->label5->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
528
			// 
529
			// numericUpDown1
530
			// 
531
			this->numericUpDown1->Dock = System::Windows::Forms::DockStyle::Left;
532
			this->numericUpDown1->Location = System::Drawing::Point(122, 0);
533
			this->numericUpDown1->Name = L"numericUpDown1";
534
			this->numericUpDown1->Size = System::Drawing::Size(51, 20);
535
			this->numericUpDown1->TabIndex = 3;
536
			// 
537
			// label4
538
			// 
539
			this->label4->Dock = System::Windows::Forms::DockStyle::Left;
540
			this->label4->Location = System::Drawing::Point(0, 0);
541
			this->label4->Name = L"label4";
542
			this->label4->Size = System::Drawing::Size(122, 20);
543
			this->label4->TabIndex = 4;
544
			this->label4->Text = L"Cap Fake Patch To";
545
			this->label4->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
546
			// 
547
			// textBox3
548
			// 
549
			this->textBox3->Dock = System::Windows::Forms::DockStyle::Top;
550
			this->textBox3->Location = System::Drawing::Point(0, 0);
551
			this->textBox3->Name = L"textBox3";
552
			this->textBox3->ReadOnly = true;
553
			this->textBox3->Size = System::Drawing::Size(371, 20);
554
			this->textBox3->TabIndex = 0;
555
			// 
556
			// label3
557
			// 
558
			this->label3->Dock = System::Windows::Forms::DockStyle::Left;
559
			this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
560
				static_cast<System::Byte>(0)));
561
			this->label3->Location = System::Drawing::Point(5, 5);
562
			this->label3->Name = L"label3";
563
			this->label3->Size = System::Drawing::Size(155, 40);
564
			this->label3->TabIndex = 2;
565
			this->label3->Text = L"Game Directory";
566
			this->label3->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
567
			// 
568
			// button3
569
			// 
570
			this->button3->AutoSize = true;
571
			this->button3->Dock = System::Windows::Forms::DockStyle::Right;
572
			this->button3->Location = System::Drawing::Point(531, 5);
573
			this->button3->Name = L"button3";
574
			this->button3->Size = System::Drawing::Size(28, 40);
575
			this->button3->TabIndex = 1;
576
			this->button3->Text = L"...";
577
			this->button3->UseVisualStyleBackColor = true;
578
			this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
579
			// 
580
			// panel6
581
			// 
582
			this->panel6->Controls->Add(this->button5);
583
			this->panel6->Controls->Add(this->button4);
584
			this->panel6->Dock = System::Windows::Forms::DockStyle::Bottom;
585
			this->panel6->Location = System::Drawing::Point(0, 507);
586
			this->panel6->Name = L"panel6";
587
			this->panel6->Padding = System::Windows::Forms::Padding(10);
588
			this->panel6->Size = System::Drawing::Size(564, 48);
589
			this->panel6->TabIndex = 9;
590
			// 
591
			// button5
592
			// 
593
			this->button5->DialogResult = System::Windows::Forms::DialogResult::Abort;
594
			this->button5->Dock = System::Windows::Forms::DockStyle::Right;
595
			this->button5->ForeColor = System::Drawing::Color::DarkRed;
596
			this->button5->Location = System::Drawing::Point(436, 10);
597
			this->button5->Name = L"button5";
598
			this->button5->Size = System::Drawing::Size(118, 28);
599
			this->button5->TabIndex = 1;
600
			this->button5->Text = L"Exit";
601
			this->button5->UseVisualStyleBackColor = true;
602
			this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
603
			// 
604
			// button4
605
			// 
606
			this->button4->Dock = System::Windows::Forms::DockStyle::Left;
607
			this->button4->Enabled = false;
608
			this->button4->ForeColor = System::Drawing::Color::ForestGreen;
609
			this->button4->Location = System::Drawing::Point(10, 10);
610
			this->button4->Name = L"button4";
611
			this->button4->Size = System::Drawing::Size(116, 28);
612
			this->button4->TabIndex = 0;
613
			this->button4->Text = L"Merge";
614
			this->button4->UseVisualStyleBackColor = true;
615
			this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
616
			// 
617
			// Form1
618
			// 
619
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
620
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
621
			this->CancelButton = this->button5;
622
			this->ClientSize = System::Drawing::Size(564, 555);
623
			this->Controls->Add(this->treeView1);
624
			this->Controls->Add(this->panel6);
625
			this->Controls->Add(this->panel2);
626
			this->Controls->Add(this->panel1);
627
			this->Controls->Add(this->panel3);
628
			this->Name = L"Form1";
629
			this->Text = L"Mod Merger";
630
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
631
			this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &Form1::Form1_FormClosing);
632
			this->panel1->ResumeLayout(false);
633
			this->panel1->PerformLayout();
634
			this->panel2->ResumeLayout(false);
635
			this->panel2->PerformLayout();
636
			this->panel3->ResumeLayout(false);
637
			this->panel3->PerformLayout();
638
			this->panel5->ResumeLayout(false);
639
			this->panel5->PerformLayout();
640
			this->panel4->ResumeLayout(false);
641
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->EndInit();
642
			this->panel6->ResumeLayout(false);
643
			this->ResumeLayout(false);
644
 
645
		}
646
#pragma endregion
647
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
648
			String ^openfile = this->OpenFile("Select the mod file to use as the primary mod");
649
			if ( openfile )
650
			{
651
				if ( m_pFile1->Open(CyStringFromSystemString(openfile), "", CATREAD_CATDECRYPT, false) == CATERR_NONE )
652
				{
653
					this->textBox1->Text = openfile;
654
					this->panel2->Enabled = true;
655
				}
656
				else
657
					MessageBox::Show(this, "Unable to open mod file\n" + openfile, "Error Opening", MessageBoxButtons::OK, MessageBoxIcon::Error);
658
			}
659
		}
660
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
661
			String ^openfile = this->OpenFile("Select the mod file to use as the secondary mod");
662
			if ( openfile )
663
			{
664
				if ( m_pFile2->Open(CyStringFromSystemString(openfile), "", CATREAD_CATDECRYPT, false) == CATERR_NONE )
665
				{
666
					this->textBox2->Text = openfile;
667
					this->UpdateFileList();
668
				}
669
				else
670
					MessageBox::Show(this, "Unable to open mod file\n" + openfile, "Error Opening", MessageBoxButtons::OK, MessageBoxIcon::Error);
671
			}
672
		 }
673
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
674
			 DoGameDirectory();
675
		 }
676
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
677
			 Close();
678
		 }
679
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
680
			 StartMerge();
681
		 }
682
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
683
			 LoadData();
684
		 }
685
private: System::Void Form1_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
686
			 SaveData();
687
		 }
688
};
689
}
690