Subversion Repositories spk

Rev

Rev 118 | Rev 124 | Go to most recent revision | 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
					{
58 cycrow 83
						if ( m_pPackages->CanWeMerge(str->str.ToString()) )
1 cycrow 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;
58 cycrow 143
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK ) {
144
				if ( ofd->FileName == this->textBox1->Text || ofd->FileName == this->textBox2->Text )
145
					MessageBox::Show(this, "Error: Unable to save to file: " + ofd->FileName + "\nYou must not select the same file name as the primary or secondary mod", "Invalid Save File", MessageBoxButtons::OK, MessageBoxIcon::Error);
146
				else 
147
					Merge(ofd->FileName);
148
			}
1 cycrow 149
		}
150
 
151
		void Merge(String ^file)
152
		{
153
			// create the mod file by copying the primary mod
154
			if ( IO::File::Exists(file) )
155
				IO::File::Delete(file);
156
			IO::File::Copy(this->textBox1->Text, file);
157
			// and the dat file
158
			CyString file1 = CFileIO(CyStringFromSystemString(this->textBox1->Text)).ChangeFileExtension("dat");
159
			CyString file2 = CFileIO(CyStringFromSystemString(file)).ChangeFileExtension("dat");
160
			if ( IO::File::Exists(SystemStringFromCyString(file2)) )
161
				IO::File::Delete(SystemStringFromCyString(file2));
162
			IO::File::Copy(SystemStringFromCyString(file1), SystemStringFromCyString(file2));
163
 
164
			CCatFile CatFile;
165
			if ( !CCatFile::Opened(CatFile.Open(CyStringFromSystemString(file), "", CATREAD_CATDECRYPT, false), false) )
166
			{
167
				MessageBox::Show(this, "Unable to open cat file: " + file, "Merge Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
168
				return;
169
			}
170
 
171
			// now we need to move non merge files from the 2nd mod to the new one
172
			CyStringList *list = m_pPackages->GetMergedFiles(m_pFile1, m_pFile2);
173
			if ( list )
174
			{
58 cycrow 175
				CModDiff Diff(_S(this->textBox3->Text).token(" (", 1), "addon", Convert::ToInt32(this->numericUpDown1->Value));
176
				if ( Diff.startDiff(_S(this->textBox2->Text)) ) {
177
					for ( SStringList *str = list->Head(); str; str = str->next )
1 cycrow 178
					{
58 cycrow 179
						int status = str->data.ToInt();
180
						if ( status == 2 ) { // in 2nd mod
181
							if ( CatFile.AppendFile(_S(this->textBox2->Text) + "::" + str->str.ToString(), str->str.ToString()) )
182
								CatFile.WriteCatFile();
1 cycrow 183
						}
58 cycrow 184
						// finally, we need to diff the remaining files
185
						else if ( status == -1 ) { // in both
186
							// only diffable files, we ignore the rest
187
							if ( CModDiff::CanBeDiffed(str->str.ToString()) ) Diff.doDiff(str->str.ToString());
188
						}
1 cycrow 189
					}
58 cycrow 190
 
191
					Diff.ApplyDiff(_S(file));
1 cycrow 192
				}
193
				delete list;
194
			}
195
 
196
			MessageBox::Show(this, "Mod files have been merged to: " + file, "Mod Merged", MessageBoxButtons::OK, MessageBoxIcon::Information);
197
		}
198
 
199
		void LoadData()
200
		{
201
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
202
			CFileIO Config;
118 cycrow 203
			if ( Config.open(_S(mydoc) + "/Egosoft/modmerge.dat") )
1 cycrow 204
			{
205
				std::vector<CyString> *lines = Config.ReadLines();
206
				if ( lines )
207
				{
208
					for ( int i = 0; i < (int)lines->size(); i++ )
209
					{
210
						CyString line(lines->at(i));
211
						CyString start = line.GetToken(":", 1, 1).lower();
212
						CyString rest = line.GetToken(":", 2).RemoveFirstSpace();
213
						if ( start.Compare("ModMergeSize") )
214
							this->Size = System::Drawing::Size(rest.GetToken(" ", 1, 1).ToInt(), rest.GetToken(" ", 2, 2).ToInt());
215
						else if ( start.Compare("ModMergePos") )
216
						{
217
							m_iLocX = rest.GetToken(" ", 1, 1).ToInt();
218
							m_iLocY = rest.GetToken(" ", 2, 2).ToInt();
219
							if ( !this->TopMost )
220
								this->Location = System::Drawing::Point(m_iLocX, m_iLocY);
221
						}
222
						else if ( start.Compare("ModMergeMax") )
223
						{
224
							if ( !this->TopMost )
225
								this->WindowState = FormWindowState::Maximized;
226
						}
227
						else if ( start.Compare("GameDir") )
228
							SetGameDir(rest.GetToken(";", 1, 1).ToInt(), SystemStringFromCyString(rest.GetToken(";", 2)));
229
					}
230
 
231
					delete lines;
232
				}
233
			}
234
 
121 cycrow 235
			if ( m_pPackages->getCurrentDirectory().empty() )
1 cycrow 236
				DoGameDirectory();
237
		}
238
 
239
		void SaveData()
240
		{
241
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
242
			CFileIO Config(CyStringFromSystemString(mydoc) + "/Egosoft/modmerge.dat");
243
			CyStringList lines;
244
 
245
			if ( this->WindowState == FormWindowState::Normal )
246
			{
247
				lines.PushBack(CyString("ModMergeSize:") + (long)this->Size.Width + " " + (long)this->Size.Height);
248
				if ( this->TopMost )
249
				{
250
					if ( m_iLocX != -1 && m_iLocY != -1 )
251
						lines.PushBack(CyString("ModMergePos:") + (long)m_iLocX + " " + (long)m_iLocY);
252
				}
253
				else
254
					lines.PushBack(CyString("ModMergePos:") + (long)this->Location.X + " " + (long)this->Location.Y);
255
			}
256
			else
257
			{
258
				lines.PushBack(CyString("ModMergeSize:") + (long)this->RestoreBounds.Size.Width + " " + (long)this->RestoreBounds.Size.Height);
259
				if ( this->TopMost )
260
				{
261
					if ( m_iLocX != -1 && m_iLocY != -1 )
262
						lines.PushBack(CyString("ModMergePos:") + (long)m_iLocX + " " + (long)m_iLocY);
263
				}
264
				else
265
					lines.PushBack(CyString("ModMergePos:") + (long)this->RestoreBounds.Location.X + " " + (long)this->RestoreBounds.Location.Y);
266
			}
267
 
268
			if ( this->WindowState == FormWindowState::Maximized )
269
				lines.PushBack("ModMergeMax:");
270
 
271
			if ( this->textBox3->Text->Length )
121 cycrow 272
				lines.PushBack(CyString("GameDir:") + (long)Convert::ToInt32(this->numericUpDown1->Value) + ";" + m_pPackages->getCurrentDirectory());
1 cycrow 273
			Config.WriteFile(&lines);
274
		}
275
 
276
 
277
		bool SetGameDir(int patch, String ^gameDir)
278
		{
279
			CyString dir = CyStringFromSystemString(gameDir);
280
			if ( !dir.Empty() )
281
			{
282
				CyString gameName = m_pPackages->GetGameName(dir);
283
				if ( !gameName.Empty() )
284
				{
285
					this->textBox3->Text = gameDir + " (" + SystemStringFromCyString(gameName) + ")";
286
					this->panel5->Enabled = true;
287
					this->numericUpDown1->Minimum = 1;
288
					m_pPackages->SetCurrentDir(dir);
289
					this->numericUpDown1->Maximum = m_pPackages->FindNextFakePatch() - 1;
290
					if ( patch < 1 || patch > this->numericUpDown1->Maximum )
291
						this->numericUpDown1->Value = this->numericUpDown1->Maximum;
292
					else
293
						this->numericUpDown1->Value = patch;
294
					this->label5->Text = "(prevent loading added mods, max=" + Convert::ToString(this->numericUpDown1->Maximum) + ")";
295
					this->panel1->Enabled = true;
296
 
297
					return true;
298
				}
299
			}
300
 
301
			return false;
302
		}
303
 
304
	protected:
305
		/// <summary>
306
		/// Clean up any resources being used.
307
		/// </summary>
308
		~Form1()
309
		{
310
			if (components)
311
			{
312
				delete components;
313
			}
314
			if ( m_pPackages ) delete m_pPackages;
315
		}
316
 
317
#pragma region defines
318
	private:
319
		CCatFile	*m_pFile1;
320
		CCatFile	*m_pFile2;
321
		CPackages	*m_pPackages;
322
		int			m_iLocX;
323
		int			m_iLocY;
324
#pragma endregion
325
 
326
#pragma region designer defines
327
	private: System::Windows::Forms::Panel^  panel1;
328
	private: System::Windows::Forms::TextBox^  textBox1;
329
	private: System::Windows::Forms::Label^  label1;
330
	private: System::Windows::Forms::Button^  button1;
331
	private: System::Windows::Forms::Panel^  panel2;
332
	private: System::Windows::Forms::TextBox^  textBox2;
333
	private: System::Windows::Forms::Label^  label2;
334
	private: System::Windows::Forms::Button^  button2;
335
	private: System::Windows::Forms::TreeView^  treeView1;
336
private: System::Windows::Forms::Panel^  panel3;
337
private: System::Windows::Forms::Panel^  panel5;
338
private: System::Windows::Forms::Panel^  panel4;
339
private: System::Windows::Forms::NumericUpDown^  numericUpDown1;
340
private: System::Windows::Forms::Label^  label4;
341
private: System::Windows::Forms::TextBox^  textBox3;
342
private: System::Windows::Forms::Label^  label3;
343
private: System::Windows::Forms::Button^  button3;
344
private: System::Windows::Forms::Label^  label5;
345
private: System::Windows::Forms::Panel^  panel6;
346
private: System::Windows::Forms::Button^  button5;
347
private: System::Windows::Forms::Button^  button4;
348
		 /// <summary>
349
		/// Required designer variable.
350
		/// </summary>
351
		System::ComponentModel::Container ^components;
352
#pragma endregion
353
#pragma region Windows Form Designer generated code
354
		/// <summary>
355
		/// Required method for Designer support - do not modify
356
		/// the contents of this method with the code editor.
357
		/// </summary>
358
		void InitializeComponent(void)
359
		{
360
			this->panel1 = (gcnew System::Windows::Forms::Panel());
361
			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
362
			this->label1 = (gcnew System::Windows::Forms::Label());
363
			this->button1 = (gcnew System::Windows::Forms::Button());
364
			this->panel2 = (gcnew System::Windows::Forms::Panel());
365
			this->textBox2 = (gcnew System::Windows::Forms::TextBox());
366
			this->label2 = (gcnew System::Windows::Forms::Label());
367
			this->button2 = (gcnew System::Windows::Forms::Button());
368
			this->treeView1 = (gcnew System::Windows::Forms::TreeView());
369
			this->panel3 = (gcnew System::Windows::Forms::Panel());
370
			this->panel5 = (gcnew System::Windows::Forms::Panel());
371
			this->panel4 = (gcnew System::Windows::Forms::Panel());
372
			this->label5 = (gcnew System::Windows::Forms::Label());
373
			this->numericUpDown1 = (gcnew System::Windows::Forms::NumericUpDown());
374
			this->label4 = (gcnew System::Windows::Forms::Label());
375
			this->textBox3 = (gcnew System::Windows::Forms::TextBox());
376
			this->label3 = (gcnew System::Windows::Forms::Label());
377
			this->button3 = (gcnew System::Windows::Forms::Button());
378
			this->panel6 = (gcnew System::Windows::Forms::Panel());
379
			this->button5 = (gcnew System::Windows::Forms::Button());
380
			this->button4 = (gcnew System::Windows::Forms::Button());
381
			this->panel1->SuspendLayout();
382
			this->panel2->SuspendLayout();
383
			this->panel3->SuspendLayout();
384
			this->panel5->SuspendLayout();
385
			this->panel4->SuspendLayout();
386
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->BeginInit();
387
			this->panel6->SuspendLayout();
388
			this->SuspendLayout();
389
			// 
390
			// panel1
391
			// 
392
			this->panel1->Controls->Add(this->textBox1);
393
			this->panel1->Controls->Add(this->label1);
394
			this->panel1->Controls->Add(this->button1);
395
			this->panel1->Dock = System::Windows::Forms::DockStyle::Top;
396
			this->panel1->Location = System::Drawing::Point(0, 50);
397
			this->panel1->Name = L"panel1";
398
			this->panel1->Padding = System::Windows::Forms::Padding(5);
399
			this->panel1->Size = System::Drawing::Size(564, 31);
400
			this->panel1->TabIndex = 5;
401
			// 
402
			// textBox1
403
			// 
404
			this->textBox1->Dock = System::Windows::Forms::DockStyle::Fill;
405
			this->textBox1->Location = System::Drawing::Point(160, 5);
406
			this->textBox1->Name = L"textBox1";
407
			this->textBox1->ReadOnly = true;
408
			this->textBox1->Size = System::Drawing::Size(371, 20);
409
			this->textBox1->TabIndex = 0;
410
			// 
411
			// label1
412
			// 
413
			this->label1->Dock = System::Windows::Forms::DockStyle::Left;
414
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
415
				static_cast<System::Byte>(0)));
416
			this->label1->Location = System::Drawing::Point(5, 5);
417
			this->label1->Name = L"label1";
418
			this->label1->Size = System::Drawing::Size(155, 21);
419
			this->label1->TabIndex = 2;
420
			this->label1->Text = L"Primary Mod";
421
			this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
422
			// 
423
			// button1
424
			// 
425
			this->button1->AutoSize = true;
426
			this->button1->Dock = System::Windows::Forms::DockStyle::Right;
427
			this->button1->Location = System::Drawing::Point(531, 5);
428
			this->button1->Name = L"button1";
429
			this->button1->Size = System::Drawing::Size(28, 21);
430
			this->button1->TabIndex = 1;
431
			this->button1->Text = L"...";
432
			this->button1->UseVisualStyleBackColor = true;
433
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
434
			// 
435
			// panel2
436
			// 
437
			this->panel2->Controls->Add(this->textBox2);
438
			this->panel2->Controls->Add(this->label2);
439
			this->panel2->Controls->Add(this->button2);
440
			this->panel2->Dock = System::Windows::Forms::DockStyle::Top;
441
			this->panel2->Enabled = false;
442
			this->panel2->Location = System::Drawing::Point(0, 81);
443
			this->panel2->Name = L"panel2";
444
			this->panel2->Padding = System::Windows::Forms::Padding(5);
445
			this->panel2->Size = System::Drawing::Size(564, 31);
446
			this->panel2->TabIndex = 6;
447
			// 
448
			// textBox2
449
			// 
450
			this->textBox2->Dock = System::Windows::Forms::DockStyle::Fill;
451
			this->textBox2->Location = System::Drawing::Point(160, 5);
452
			this->textBox2->Name = L"textBox2";
453
			this->textBox2->ReadOnly = true;
454
			this->textBox2->Size = System::Drawing::Size(371, 20);
455
			this->textBox2->TabIndex = 0;
456
			// 
457
			// label2
458
			// 
459
			this->label2->Dock = System::Windows::Forms::DockStyle::Left;
460
			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
461
				static_cast<System::Byte>(0)));
462
			this->label2->Location = System::Drawing::Point(5, 5);
463
			this->label2->Name = L"label2";
464
			this->label2->Size = System::Drawing::Size(155, 21);
465
			this->label2->TabIndex = 2;
466
			this->label2->Text = L"Secondary Mod";
467
			this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
468
			// 
469
			// button2
470
			// 
471
			this->button2->AutoSize = true;
472
			this->button2->Dock = System::Windows::Forms::DockStyle::Right;
473
			this->button2->Location = System::Drawing::Point(531, 5);
474
			this->button2->Name = L"button2";
475
			this->button2->Size = System::Drawing::Size(28, 21);
476
			this->button2->TabIndex = 1;
477
			this->button2->Text = L"...";
478
			this->button2->UseVisualStyleBackColor = true;
479
			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
480
			// 
481
			// treeView1
482
			// 
483
			this->treeView1->Dock = System::Windows::Forms::DockStyle::Fill;
484
			this->treeView1->Location = System::Drawing::Point(0, 112);
485
			this->treeView1->Name = L"treeView1";
486
			this->treeView1->Size = System::Drawing::Size(564, 395);
487
			this->treeView1->TabIndex = 7;
488
			// 
489
			// panel3
490
			// 
491
			this->panel3->Controls->Add(this->panel5);
492
			this->panel3->Controls->Add(this->label3);
493
			this->panel3->Controls->Add(this->button3);
494
			this->panel3->Dock = System::Windows::Forms::DockStyle::Top;
495
			this->panel3->Location = System::Drawing::Point(0, 0);
496
			this->panel3->Name = L"panel3";
497
			this->panel3->Padding = System::Windows::Forms::Padding(5);
498
			this->panel3->Size = System::Drawing::Size(564, 50);
499
			this->panel3->TabIndex = 8;
500
			// 
501
			// panel5
502
			// 
503
			this->panel5->Controls->Add(this->panel4);
504
			this->panel5->Controls->Add(this->textBox3);
505
			this->panel5->Dock = System::Windows::Forms::DockStyle::Fill;
506
			this->panel5->Location = System::Drawing::Point(160, 5);
507
			this->panel5->Name = L"panel5";
508
			this->panel5->Size = System::Drawing::Size(371, 40);
509
			this->panel5->TabIndex = 6;
510
			// 
511
			// panel4
512
			// 
513
			this->panel4->Controls->Add(this->label5);
514
			this->panel4->Controls->Add(this->numericUpDown1);
515
			this->panel4->Controls->Add(this->label4);
516
			this->panel4->Dock = System::Windows::Forms::DockStyle::Fill;
517
			this->panel4->Location = System::Drawing::Point(0, 20);
518
			this->panel4->Name = L"panel4";
519
			this->panel4->Size = System::Drawing::Size(371, 20);
520
			this->panel4->TabIndex = 5;
521
			// 
522
			// label5
523
			// 
524
			this->label5->Dock = System::Windows::Forms::DockStyle::Fill;
525
			this->label5->Location = System::Drawing::Point(173, 0);
526
			this->label5->Name = L"label5";
527
			this->label5->Size = System::Drawing::Size(198, 20);
528
			this->label5->TabIndex = 5;
529
			this->label5->Text = L"(prevent loading added mods, max=)";
530
			this->label5->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
531
			// 
532
			// numericUpDown1
533
			// 
534
			this->numericUpDown1->Dock = System::Windows::Forms::DockStyle::Left;
535
			this->numericUpDown1->Location = System::Drawing::Point(122, 0);
536
			this->numericUpDown1->Name = L"numericUpDown1";
537
			this->numericUpDown1->Size = System::Drawing::Size(51, 20);
538
			this->numericUpDown1->TabIndex = 3;
539
			// 
540
			// label4
541
			// 
542
			this->label4->Dock = System::Windows::Forms::DockStyle::Left;
543
			this->label4->Location = System::Drawing::Point(0, 0);
544
			this->label4->Name = L"label4";
545
			this->label4->Size = System::Drawing::Size(122, 20);
546
			this->label4->TabIndex = 4;
547
			this->label4->Text = L"Cap Fake Patch To";
548
			this->label4->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
549
			// 
550
			// textBox3
551
			// 
552
			this->textBox3->Dock = System::Windows::Forms::DockStyle::Top;
553
			this->textBox3->Location = System::Drawing::Point(0, 0);
554
			this->textBox3->Name = L"textBox3";
555
			this->textBox3->ReadOnly = true;
556
			this->textBox3->Size = System::Drawing::Size(371, 20);
557
			this->textBox3->TabIndex = 0;
558
			// 
559
			// label3
560
			// 
561
			this->label3->Dock = System::Windows::Forms::DockStyle::Left;
562
			this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
563
				static_cast<System::Byte>(0)));
564
			this->label3->Location = System::Drawing::Point(5, 5);
565
			this->label3->Name = L"label3";
566
			this->label3->Size = System::Drawing::Size(155, 40);
567
			this->label3->TabIndex = 2;
568
			this->label3->Text = L"Game Directory";
569
			this->label3->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
570
			// 
571
			// button3
572
			// 
573
			this->button3->AutoSize = true;
574
			this->button3->Dock = System::Windows::Forms::DockStyle::Right;
575
			this->button3->Location = System::Drawing::Point(531, 5);
576
			this->button3->Name = L"button3";
577
			this->button3->Size = System::Drawing::Size(28, 40);
578
			this->button3->TabIndex = 1;
579
			this->button3->Text = L"...";
580
			this->button3->UseVisualStyleBackColor = true;
581
			this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
582
			// 
583
			// panel6
584
			// 
585
			this->panel6->Controls->Add(this->button5);
586
			this->panel6->Controls->Add(this->button4);
587
			this->panel6->Dock = System::Windows::Forms::DockStyle::Bottom;
588
			this->panel6->Location = System::Drawing::Point(0, 507);
589
			this->panel6->Name = L"panel6";
590
			this->panel6->Padding = System::Windows::Forms::Padding(10);
591
			this->panel6->Size = System::Drawing::Size(564, 48);
592
			this->panel6->TabIndex = 9;
593
			// 
594
			// button5
595
			// 
596
			this->button5->DialogResult = System::Windows::Forms::DialogResult::Abort;
597
			this->button5->Dock = System::Windows::Forms::DockStyle::Right;
598
			this->button5->ForeColor = System::Drawing::Color::DarkRed;
599
			this->button5->Location = System::Drawing::Point(436, 10);
600
			this->button5->Name = L"button5";
601
			this->button5->Size = System::Drawing::Size(118, 28);
602
			this->button5->TabIndex = 1;
603
			this->button5->Text = L"Exit";
604
			this->button5->UseVisualStyleBackColor = true;
605
			this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
606
			// 
607
			// button4
608
			// 
609
			this->button4->Dock = System::Windows::Forms::DockStyle::Left;
610
			this->button4->Enabled = false;
611
			this->button4->ForeColor = System::Drawing::Color::ForestGreen;
612
			this->button4->Location = System::Drawing::Point(10, 10);
613
			this->button4->Name = L"button4";
614
			this->button4->Size = System::Drawing::Size(116, 28);
615
			this->button4->TabIndex = 0;
616
			this->button4->Text = L"Merge";
617
			this->button4->UseVisualStyleBackColor = true;
618
			this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
619
			// 
620
			// Form1
621
			// 
622
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
623
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
624
			this->CancelButton = this->button5;
625
			this->ClientSize = System::Drawing::Size(564, 555);
626
			this->Controls->Add(this->treeView1);
627
			this->Controls->Add(this->panel6);
628
			this->Controls->Add(this->panel2);
629
			this->Controls->Add(this->panel1);
630
			this->Controls->Add(this->panel3);
631
			this->Name = L"Form1";
632
			this->Text = L"Mod Merger";
633
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
634
			this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &Form1::Form1_FormClosing);
635
			this->panel1->ResumeLayout(false);
636
			this->panel1->PerformLayout();
637
			this->panel2->ResumeLayout(false);
638
			this->panel2->PerformLayout();
639
			this->panel3->ResumeLayout(false);
640
			this->panel3->PerformLayout();
641
			this->panel5->ResumeLayout(false);
642
			this->panel5->PerformLayout();
643
			this->panel4->ResumeLayout(false);
644
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->numericUpDown1))->EndInit();
645
			this->panel6->ResumeLayout(false);
646
			this->ResumeLayout(false);
647
 
648
		}
649
#pragma endregion
650
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
651
			String ^openfile = this->OpenFile("Select the mod file to use as the primary mod");
652
			if ( openfile )
653
			{
654
				if ( m_pFile1->Open(CyStringFromSystemString(openfile), "", CATREAD_CATDECRYPT, false) == CATERR_NONE )
655
				{
656
					this->textBox1->Text = openfile;
657
					this->panel2->Enabled = true;
658
				}
659
				else
660
					MessageBox::Show(this, "Unable to open mod file\n" + openfile, "Error Opening", MessageBoxButtons::OK, MessageBoxIcon::Error);
661
			}
662
		}
663
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
664
			String ^openfile = this->OpenFile("Select the mod file to use as the secondary mod");
665
			if ( openfile )
666
			{
667
				if ( m_pFile2->Open(CyStringFromSystemString(openfile), "", CATREAD_CATDECRYPT, false) == CATERR_NONE )
668
				{
669
					this->textBox2->Text = openfile;
670
					this->UpdateFileList();
671
				}
672
				else
673
					MessageBox::Show(this, "Unable to open mod file\n" + openfile, "Error Opening", MessageBoxButtons::OK, MessageBoxIcon::Error);
674
			}
675
		 }
676
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
677
			 DoGameDirectory();
678
		 }
679
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
680
			 Close();
681
		 }
682
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
683
			 StartMerge();
684
		 }
685
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
686
			 LoadData();
687
		 }
688
private: System::Void Form1_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e) {
689
			 SaveData();
690
		 }
691
};
692
}
693