Subversion Repositories spk

Rev

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