Subversion Repositories spk

Rev

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
#include <spk.h>
4
 
5
#define VERSION 1.30
6
 
7
#undef GetTempPath
8
 
9
namespace XspConvert {
10
 
11
	using namespace System;
12
	using namespace System::ComponentModel;
13
	using namespace System::Collections;
14
	using namespace System::Windows::Forms;
15
	using namespace System::Data;
16
	using namespace System::Drawing;
17
 
18
	/// <summary>
19
	/// Summary for Form1
20
	///
21
	/// WARNING: If you change the name of this class, you will need to change the
22
	///          'Resource File Name' property for the managed resource compiler tool
23
	///          associated with all .resx files this class depends on.  Otherwise,
24
	///          the designers will not be able to interact properly with localized
25
	///          resources associated with this form.
26
	/// </summary>
27
	public ref class Form1 : public System::Windows::Forms::Form
28
	{
29
	public:
30
		Form1(System::String ^open)
31
		{
32
			InitializeComponent();
33
 
34
			this->UpdateTitle();
35
 
36
			m_bLoading = false;
37
			m_bDontChange = false;
38
			m_bDontUpdate = false;
39
			m_bChanged = false;
40
			m_bReadText = false;
41
			m_pLoadedShip = NULL;
223 cycrow 42
			m_pDirList = new Utils::WStringList;
43
			m_pTextList = new CLinkList<Utils::WStringList>;
44
			m_pLaserList = new CLinkList<Utils::WStringList>;
45
			m_pMissileList = new CLinkList<Utils::WStringList>;
1 cycrow 46
			m_pCockpit = NULL;
47
			this->PanelMain->Hide();
48
			this->PanelNotLoaded->Show();
49
 
50
			m_iOldGame = -1;
51
 
52
			this->Setup();
53
 
54
			if ( open )
55
				m_sOpenFile = open;
56
		}
57
 
58
	protected:
59
		/// <summary>
60
		/// Clean up any resources being used.
61
		/// </summary>
62
		~Form1()
63
		{
64
			if ( m_pLoadedShip )
65
				delete m_pLoadedShip;
66
			if ( m_pDirList )
67
				delete m_pDirList;
68
			if ( m_pTextList )
69
				delete m_pTextList;
70
			if ( m_pLaserList )
71
				delete m_pLaserList;
72
			if ( m_pMissileList )
73
				delete m_pMissileList;
74
 
75
			if (components)
76
			{
77
				delete components;
78
			}
79
		}
80
	private: System::Windows::Forms::MenuStrip^  menuStrip1;
81
	protected: 
82
	private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;
83
	private: System::Windows::Forms::ToolStripMenuItem^  openToolStripMenuItem;
84
	private: System::Windows::Forms::Panel^  panel1;
85
	private: System::Windows::Forms::Button^  ButExit;
86
	private: System::Windows::Forms::Panel^  PanelMain;
87
 
88
 
89
	private:
90
		bool		m_bLoading;
91
		bool		m_bDontUpdate;
92
		bool		m_bChanged;
93
		bool		m_bReadText;
94
		bool		m_bDontChange;
223 cycrow 95
		Utils::WStringList *m_pDirList;
96
		CLinkList<Utils::WStringList> *m_pTextList;
97
		CLinkList<Utils::WStringList> *m_pLaserList;
98
		CLinkList<Utils::WStringList> *m_pMissileList;
1 cycrow 99
		CXspFile	*m_pLoadedShip;
100
		int			 m_iOldGame;
101
		array<System::Windows::Forms::ToolStripMenuItem^> ^m_aTools;
102
		System::String ^m_sOpenFile;
103
		SCockpit	*m_pCockpit;
104
 
105
		int			m_iLoadedLaserMask;
106
		int			m_iLoadedMissileMask;
107
		int			m_iLaserMask;
108
		int			m_iMissileMask;
109
 
110
	private: System::Windows::Forms::Panel^  PanelNotLoaded;
111
	private: System::Windows::Forms::Label^  LabelNotLoaded;
112
	private: System::Windows::Forms::ComboBox^  ComboGame;
113
 
114
	private: System::Windows::Forms::Panel^  panel2;
115
	private: System::Windows::Forms::Label^  label1;
116
	private: System::Windows::Forms::ToolStripMenuItem^  saveToolStripMenuItem;
117
	private: System::Windows::Forms::CheckedListBox^  WeaponList;
118
 
119
	private: System::Windows::Forms::ToolStripMenuItem^  settingsToolStripMenuItem;
120
	private: System::Windows::Forms::ToolStripMenuItem^  gamesToolStripMenuItem;
121
	private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator1;
122
	private: System::Windows::Forms::ToolStripMenuItem^  updateGameDataToolStripMenuItem;
123
	private: System::Windows::Forms::TabControl^  tabControl1;
124
	private: System::Windows::Forms::TabPage^  tabPage1;
125
	private: System::Windows::Forms::TabPage^  tabPage2;
126
	private: System::Windows::Forms::CheckedListBox^  MissileList;
127
	private: System::Windows::Forms::ToolStripMenuItem^  loadGameTextToolStripMenuItem;
128
	private: System::Windows::Forms::ToolStripMenuItem^  saveAsToolStripMenuItem;
129
	private: System::Windows::Forms::TabPage^  tabPage3;
130
	private: System::Windows::Forms::CheckedListBox^  CockpitWeapons;
131
	private: System::Windows::Forms::ComboBox^  ComboCockpits;
132
 
133
 
134
		/// <summary>
135
		/// Required designer variable.
136
		/// </summary>
137
		System::ComponentModel::Container ^components;
138
 
139
#pragma region Windows Form Designer generated code
140
		/// <summary>
141
		/// Required method for Designer support - do not modify
142
		/// the contents of this method with the code editor.
143
		/// </summary>
144
		void Setup()
145
		{
146
			this->Closed += gcnew System::EventHandler(this, &Form1::CloseEvent);
147
			this->CockpitWeapons->ItemCheck += gcnew ItemCheckEventHandler(this, &Form1::Event_Changed);
148
 
149
			// read data file
150
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
151
			CFileIO Config;
223 cycrow 152
			if ( Config.open(_WS(mydoc) + L"/Egosoft/xspconvert.dat") )
1 cycrow 153
			{
223 cycrow 154
				std::vector<Utils::WString> lines;
155
				if(Config.readLines(lines))
1 cycrow 156
				{
223 cycrow 157
					for (size_t i = 0; i < lines.size(); i++ )
1 cycrow 158
					{
223 cycrow 159
						Utils::WString line(lines.at(i));
160
						Utils::WString start = line.token(L":", 1).toLower();
161
						Utils::WString rest = line.tokens(L":", 2).removeFirstSpace();
162
						if ( start.Compare(L"Dir") )
1 cycrow 163
						{
223 cycrow 164
							Utils::WString game = rest.token(L" ", 1);
165
							Utils::WString dir = rest.tokens(L" ", 2);
166
							Utils::WString find = m_pDirList->findData(game);
167
							if (!find.empty())
168
								m_pDirList->remove(find);
169
							m_pDirList->pushBack(dir, game);
1 cycrow 170
						}
223 cycrow 171
						else if ( line.Compare(L"ReadText") )
1 cycrow 172
							m_bReadText = true;
173
					}
174
				}
175
			}
176
 
177
			this->UpdateGames();
178
 
179
			this->loadGameTextToolStripMenuItem->Checked = m_bReadText;
180
		}
181
 
182
		void UpdateGames()
183
		{
184
			this->gamesToolStripMenuItem->DropDownItems->Clear();
185
			this->ComboGame->Items->Clear();
186
 
187
			CPackages p;
213 cycrow 188
			p.startup(L".", L".", L".");
1 cycrow 189
			// start at 1 to skip X2
197 cycrow 190
			for ( int i = 1; i < p.GetGameExe()->numGames(); i++ )
1 cycrow 191
			{
192
				bool added = false;
223 cycrow 193
				Utils::WString find = m_pDirList->findData(Utils::WString::Number(i));
194
				if (!find.empty())
1 cycrow 195
				{
223 cycrow 196
					if(find != L"-1")
1 cycrow 197
						added = true;
198
				}
199
 
197 cycrow 200
				SGameExe *exe = p.GetGameExe()->game(i);
191 cycrow 201
				this->ComboGame->Items->Add(_US(exe->sName));
1 cycrow 202
				System::Windows::Forms::ToolStripMenuItem ^newMenu = gcnew System::Windows::Forms::ToolStripMenuItem;
191 cycrow 203
				newMenu->Text = _US(exe->sName);
1 cycrow 204
				this->gamesToolStripMenuItem->DropDownItems->Add(newMenu);
205
				System::Windows::Forms::ToolStripMenuItem ^newMenuDir = gcnew System::Windows::Forms::ToolStripMenuItem;
206
				if ( added )
223 cycrow 207
					newMenuDir->Text = _US(m_pDirList->findData(Utils::WString::Number(i)));
1 cycrow 208
				else
209
					newMenuDir->Text = "No Directory";
210
				newMenuDir->Enabled = false;
211
				newMenu->DropDownItems->Add(newMenuDir);
212
				newMenu->DropDownItems->Add(gcnew System::Windows::Forms::ToolStripSeparator);
213
				System::Windows::Forms::ToolStripMenuItem ^newMenuChange = gcnew System::Windows::Forms::ToolStripMenuItem;
214
				newMenuChange->Text = "Set Directory";
191 cycrow 215
				newMenuChange->Tag = _US(Utils::String::Number(i)) + " " + _US(exe->sName);
1 cycrow 216
				newMenuChange->Click += gcnew System::EventHandler(this, &Form1::Event_ChangeDirectory);
217
				newMenu->DropDownItems->Add(newMenuChange);
218
 
219
				if ( added )
220
				{
221
					System::Windows::Forms::ToolStripMenuItem ^newMenuRemove = gcnew System::Windows::Forms::ToolStripMenuItem;
222
					newMenu->DropDownItems->Add(newMenuRemove);
223
					newMenuRemove->Text = "Remove Directory";
191 cycrow 224
					newMenuRemove->Tag = _US(Utils::String::Number(i)) + " " + _US(exe->sName);
1 cycrow 225
					newMenuRemove->Click += gcnew System::EventHandler(this, &Form1::Event_RemoveDirectory);
226
				}
227
			}
228
		}
229
 
230
		void UpdateTitle()
231
		{
191 cycrow 232
			System::String ^title = "XSP Convertor V" + _US(Utils::String::FromFloat((float)VERSION, 2));
1 cycrow 233
			if ( m_pLoadedShip )
234
			{
50 cycrow 235
				if ( m_bChanged || m_pLoadedShip->hasChanged() )
236
					this->Text = title + " [*" + _US(m_pLoadedShip->filename()) + "]";
1 cycrow 237
				else
50 cycrow 238
					this->Text = title + " [" + _US(m_pLoadedShip->filename()) + "]";
1 cycrow 239
			}
240
			else
241
				this->Text = title;
242
		}
243
 
244
		void SaveShip()
245
		{
246
			if ( !m_pLoadedShip )
247
				MessageBox::Show(this, "There is currently no ship loaded to convert", "Ship Save", MessageBoxButtons::OK, MessageBoxIcon::Warning);
248
			else
249
			{
250
				this->SaveMasks();
197 cycrow 251
				if ( m_pLoadedShip->writeFile(m_pLoadedShip->filename().toString()) )
1 cycrow 252
				{
50 cycrow 253
					MessageBox::Show(this, "Ship File: " + _US(m_pLoadedShip->filename()) + "\n\nHas been written", "Ship Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);
1 cycrow 254
					m_bChanged = false;
255
				}
256
			}
257
 
258
			this->UpdateTitle();
259
		}
260
 
261
		void SaveShipAs()
262
		{
263
			if ( !m_pLoadedShip )
264
				MessageBox::Show(this, "There is currently no ship loaded to convert", "Ship Save", MessageBoxButtons::OK, MessageBoxIcon::Warning);
265
			else
266
			{
267
				SaveFileDialog ^ofd = gcnew SaveFileDialog();
268
				ofd->Filter = "Ship Files (*.xsp)|*.xsp";
269
				ofd->FilterIndex = 1;
270
				ofd->RestoreDirectory = true;
271
				if ( ofd->ShowDialog() == System::Windows::Forms::DialogResult::OK )
272
				{
273
					this->SaveMasks();
224 cycrow 274
					if ( m_pLoadedShip->writeFile(_WS(ofd->FileName)) )
1 cycrow 275
					{
276
						MessageBox::Show(this, "Ship File: " + ofd->FileName + "\n\nHas been written", "Ship Saved", MessageBoxButtons::OK, MessageBoxIcon::Information);
277
						m_bChanged = false;
278
					}
279
				}
280
			}
281
 
282
			this->UpdateTitle();
283
		}
284
 
223 cycrow 285
		Utils::WString GetObjectString(int desc, const Utils::WString &idText)
1 cycrow 286
		{
287
			if ( m_bReadText )
288
			{
289
				if ( this->ComboGame->SelectedIndex < m_pMissileList->size() )
290
				{
223 cycrow 291
					Utils::WStringList *textList = m_pTextList->Get(this->ComboGame->SelectedIndex);
1 cycrow 292
					if ( textList )
293
					{
223 cycrow 294
						Utils::WString str = textList->findData(Utils::WString::Number(desc));
295
						if (str)
1 cycrow 296
						{
297
							// perform recursive lookup
223 cycrow 298
							while (str.contains(L"{17,") && str.contains(L"}"))
1 cycrow 299
							{
223 cycrow 300
								int pos = str.findPos(L"{17,");
1 cycrow 301
								pos += 4;
223 cycrow 302
								Utils::WString check = str.right(-pos);
303
								check = check.token(L"}", 1);
304
								int num = check.toInt();
305
								Utils::WString newDesc = this->GetObjectString(num, L"#" + check + L"#");
306
								str = str.findReplace(L"{17," + check + L"}", newDesc);
1 cycrow 307
							}
308
 
309
							// remove anything in brackets
223 cycrow 310
							while(str.contains(L"(") && str.contains(L")"))
1 cycrow 311
							{
223 cycrow 312
								int pos = str.findPos(L"(");
313
								str.erase(pos, (str.findPos(L")", pos) + 1) - pos);
1 cycrow 314
							}
223 cycrow 315
							return str;
1 cycrow 316
						}
317
					}
318
				}
319
			}
320
			return idText;
321
		}
322
 
323
		void UpdateNames()
324
		{
325
			this->WeaponList->Items->Clear();
326
			this->MissileList->Items->Clear();
327
			this->CockpitWeapons->Items->Clear();
328
			bool addedLaser = false;
329
			bool addedMissile = false;
330
 
223 cycrow 331
			Utils::WStringList missiles;
1 cycrow 332
			if ( this->ComboGame->SelectedIndex < m_pMissileList->size() )
333
			{
223 cycrow 334
				Utils::WStringList *missileList = m_pMissileList->Get(this->ComboGame->SelectedIndex);
1 cycrow 335
				if ( missileList )
336
				{
223 cycrow 337
					for(auto itr = missileList->begin(); itr != missileList->end(); itr++)
1 cycrow 338
					{
223 cycrow 339
						Utils::WString id = (*itr)->str.token(L";", 6);
340
						Utils::WStringNode* found = missiles[id];
341
						Utils::WString str = this->GetObjectString((*itr)->str.token(L";", 7).toInt(), (*itr)->str.token(L";", 37));
1 cycrow 342
						if ( found )
343
						{
223 cycrow 344
							found->data += L", ";
1 cycrow 345
							found->data += str;
346
						}
347
						else
223 cycrow 348
							missiles.pushBack(id, str);
1 cycrow 349
					}
350
				}
351
			}
352
 
223 cycrow 353
			Utils::WStringList lasers;
1 cycrow 354
			if ( this->ComboGame->SelectedIndex < m_pLaserList->size() )
355
			{
223 cycrow 356
				Utils::WStringList *laserList = m_pLaserList->Get(this->ComboGame->SelectedIndex);
1 cycrow 357
				if ( laserList )
358
				{
223 cycrow 359
					for (auto itr = laserList->begin(); itr != laserList->end(); itr++)
1 cycrow 360
					{
223 cycrow 361
						Utils::WString id = (*itr)->str.token(L";", 6);
362
						Utils::WStringNode* found = lasers[id];
363
						Utils::WString str = this->GetObjectString((*itr)->str.token(L";", 7).toInt(), (*itr)->str.token(L";", 23));
1 cycrow 364
						if ( found )
365
						{
223 cycrow 366
							found->data += L", ";
1 cycrow 367
							found->data += str;
368
						}
369
						else
223 cycrow 370
							lasers.pushBack(id, str);
1 cycrow 371
					}
372
				}
373
			}
374
 
223 cycrow 375
			for (size_t i = 0; i < 32; i++ )
1 cycrow 376
			{
223 cycrow 377
				if ( lasers.size() > i )
1 cycrow 378
				{
223 cycrow 379
					this->WeaponList->Items->Add(_US(lasers[i]->data));
380
					this->CockpitWeapons->Items->Add(_US(lasers[i]->data));
1 cycrow 381
					addedLaser = true;
382
				}
383
 
223 cycrow 384
				if ( missiles.size() > i )
1 cycrow 385
				{
223 cycrow 386
					this->MissileList->Items->Add(_US(missiles[i]->data));
1 cycrow 387
					addedMissile = true;
388
				}
389
 
390
				if ( !addedLaser )
391
				{
223 cycrow 392
					this->WeaponList->Items->Add(_US(Utils::WString::Number(i + 1)));
393
					this->CockpitWeapons->Items->Add(_US(Utils::WString::Number(i + 1)));
1 cycrow 394
				}
395
				if ( !addedMissile )
223 cycrow 396
					this->MissileList->Items->Add(_US(Utils::WString::Number(i + 1)));
1 cycrow 397
			}
398
		}
399
 
400
		void OpenFile(System::String ^open)
401
		{
402
				CXspFile *shipFile = new CXspFile;
197 cycrow 403
				int check = CSpkFile::CheckFile(_WS(open));
1 cycrow 404
				bool loaded = false;
405
 
406
				m_bChanged = false;
407
 
408
				if ( check == SPKFILE_SINGLESHIP )
218 cycrow 409
					loaded = shipFile->readFile(_WS(open));
1 cycrow 410
				else if ( check == SPKFILE_INVALID )
411
				{
218 cycrow 412
					loaded = shipFile->convertOld(_WS(open));
1 cycrow 413
					if ( loaded )
414
						m_bChanged = true;
415
				}
416
 
417
				this->ComboCockpits->Items->Clear();
418
 
419
				m_pCockpit = NULL;
420
 
421
				if ( loaded )
422
				{
423
					m_bLoading = true;
424
					if ( m_pLoadedShip )
425
						delete m_pLoadedShip;
426
					m_pLoadedShip = shipFile;
218 cycrow 427
					m_pLoadedShip->setFilename(_WS(open));
1 cycrow 428
 
429
					this->PanelMain->Show();
430
					this->PanelNotLoaded->Hide();
431
 
432
					m_iOldGame = -1;
433
 
434
					if ( m_pLoadedShip->AnyCockpits() )
435
					{
436
						for ( SCockpit *c = m_pLoadedShip->GetCockpits()->First(); c; c = m_pLoadedShip->GetCockpits()->Next() )
216 cycrow 437
							this->ComboCockpits->Items->Add(_US(c->sCockpit.token(L";", 19)));
1 cycrow 438
						this->CockpitWeapons->Show();
439
						this->ComboCockpits->Enabled = true;
440
						//m_pCockpit = m_pLoadedShip->GetCockpits()->First();
441
					}
442
					else
443
					{
444
						this->CockpitWeapons->Hide();
445
						this->ComboCockpits->Enabled = false;
446
					}
447
 
448
					this->ComboGame->SelectedIndex = 0;
449
					if ( this->ComboCockpits->Items->Count )
450
						this->ComboCockpits->SelectedIndex = 0;
451
 
452
					m_bChanged = false;
453
					this->UpdateTitle();
454
 
455
					MessageBox::Show(this, "Ship File: " + open + "\nHas been loaded", "Ship Loaded", MessageBoxButtons::OK, MessageBoxIcon::Information);
456
				}
457
				else
458
				{
459
					delete shipFile;
460
					if ( m_pLoadedShip )
461
					{
462
						this->PanelMain->Hide();
463
						this->PanelNotLoaded->Show();
464
					}
465
					else
466
					{
467
						this->PanelMain->Show();
468
						this->PanelNotLoaded->Hide();
469
					}
470
 
471
					MessageBox::Show(this, "Ship File: " + open + "\nHas failed to load", "Ship Failed", MessageBoxButtons::OK, MessageBoxIcon::Information);
472
				}
473
 
474
				m_bLoading = false;
475
		}
476
 
477
		void CheckSave()
478
		{
50 cycrow 479
			 if ( (m_pLoadedShip && m_pLoadedShip->hasChanged()) || m_bChanged )
1 cycrow 480
			 {
481
				 if ( MessageBox::Show(this, "The current ship has been modified, do you wish to save it?", "Save Ship", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
482
					 this->SaveShip();				 
483
			 }
484
		}
485
		void OpenFile()
486
		{
487
			// check if we need to save
488
			this->CheckSave();
489
 
490
			OpenFileDialog ^ofd = gcnew OpenFileDialog();
491
			ofd->Filter = "Ship Files (*.xsp)|*.xsp";
492
			ofd->FilterIndex = 1;
493
			ofd->RestoreDirectory = true;
494
 
495
			if ( ofd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
496
				this->OpenFile(ofd->FileName);
497
 
498
			this->UpdateTitle();
499
		}
500
 
501
		void LoadGameData()
502
		{
503
			m_pLaserList->MemoryClear();
504
			m_pMissileList->MemoryClear();
505
			m_pTextList->MemoryClear();
506
 
507
			System::String ^tempDir = System::IO::Path::GetTempPath();
223 cycrow 508
			Utils::WString sTempDir = _WS(tempDir);
1 cycrow 509
 
510
			CPackages p;
511
			bool tcText = false;
223 cycrow 512
			for(auto itr = m_pDirList->begin(); itr != m_pDirList->end(); itr++)
1 cycrow 513
			{
223 cycrow 514
				Utils::WStringList *laserList = new Utils::WStringList;
1 cycrow 515
				m_pLaserList->push_back(laserList);
223 cycrow 516
				Utils::WStringList *missileList = new Utils::WStringList;
1 cycrow 517
				m_pMissileList->push_back(missileList);
223 cycrow 518
				Utils::WStringList *textList = new Utils::WStringList;
1 cycrow 519
				m_pTextList->push_back(textList);
520
 
223 cycrow 521
				if ( p.extractGameFile(L"types/TLaser.pck", sTempDir + L"/TLaser.txt", (*itr)->str) )
1 cycrow 522
				{
223 cycrow 523
					CFileIO Open(sTempDir + L"/TLaser.txt");
524
					std::vector<Utils::WString> lines;
525
					if(Open.readLines(lines))
1 cycrow 526
					{
527
						bool first = false;
223 cycrow 528
						for ( int j = 0; j < (int)lines.size(); j++ )
1 cycrow 529
						{
223 cycrow 530
							Utils::WString line(lines.at(j));			
1 cycrow 531
							if ( line[0] == '/' )
532
								continue;
160 cycrow 533
							line.removeChar('\r');
534
							line = line.removeFirstSpace();
535
							line = line.removeEndSpace();
536
							if ( line.empty() )
1 cycrow 537
								continue;
538
							if ( !first )
539
							{
540
								first = true;
541
								continue;
542
							}
543
 
223 cycrow 544
							laserList->pushBack(line);
1 cycrow 545
						}
546
					}
547
 
52 cycrow 548
					Open.remove();
1 cycrow 549
				}
550
 
223 cycrow 551
				if ( p.extractGameFile(L"types/TMissiles.pck", sTempDir + L"/TMissiles.txt", (*itr)->str) )
1 cycrow 552
				{
213 cycrow 553
					CFileIO Open(sTempDir + L"/TMissiles.txt");
223 cycrow 554
					std::vector<Utils::WString> lines;
555
					if(Open.readLines(lines))
1 cycrow 556
					{
557
						bool first = false;
223 cycrow 558
						for ( int j = 0; j < (int)lines.size(); j++ )
1 cycrow 559
						{
223 cycrow 560
							Utils::WString line(lines.at(j));			
1 cycrow 561
							if ( line[0] == '/' )
562
								continue;
160 cycrow 563
							line.removeChar('\r');
564
							line = line.removeFirstSpace();
565
							line = line.removeEndSpace();
566
							if ( line.empty() )
1 cycrow 567
								continue;
568
							if ( !first )
569
							{
570
								first = true;
571
								continue;
572
							}
573
 
223 cycrow 574
							missileList->pushBack(line);
1 cycrow 575
						}
576
					}
577
 
52 cycrow 578
					Open.remove();
1 cycrow 579
				}
580
 
581
				if ( !m_bReadText )
582
					continue;
583
 
584
				// load the text file
223 cycrow 585
				Utils::WString textFormat;
1 cycrow 586
				if ( tcText )
223 cycrow 587
					textFormat = L"0001-L044";
1 cycrow 588
				else
223 cycrow 589
					textFormat = L"440001";
1 cycrow 590
 
223 cycrow 591
				if ( p.extractGameFile(L"t/" + textFormat + L".pck", sTempDir + L"/" + textFormat + L".xml", (*itr)->str) )
1 cycrow 592
				{
223 cycrow 593
					CFileIO Open(sTempDir + textFormat + L".xml");
82 cycrow 594
					if ( Open.startRead() )
1 cycrow 595
					{
596
						int donePage = (tcText) ? 3 : 2;
597
						int inPage = 0;
82 cycrow 598
						while ( !Open.atEnd() )
1 cycrow 599
						{
223 cycrow 600
							Utils::WString line = Open.readEndOfLine();
182 cycrow 601
							if ( line.empty() )
1 cycrow 602
								continue;
182 cycrow 603
							line = line.removeFirstSpace();
604
							line = line.remove('\t');
1 cycrow 605
							if ( !inPage )
606
							{
223 cycrow 607
								if ( line.left(5).Compare(L"<page") )
1 cycrow 608
								{
223 cycrow 609
									int pos = line.findPos(L" id=\"");
1 cycrow 610
									if ( pos != -1 )
611
									{
223 cycrow 612
										int endpos = line.findPos(L"\"", pos + 5);
1 cycrow 613
										if ( endpos != -1 )
614
										{
223 cycrow 615
											Utils::WString check = line.mid(pos + 6, endpos - pos - 5);
182 cycrow 616
											int iPage = check.toInt();
223 cycrow 617
											if ( iPage == 17 || iPage == 300017 || iPage == 350017 || iPage == 380017 || iPage == 390017)
1 cycrow 618
												inPage = iPage;
619
										}
620
									}
621
								}
622
							}
623
							else
624
							{
223 cycrow 625
								if ( line.left(6).Compare(L"</page") )
1 cycrow 626
								{
627
									inPage = 0;
628
									--donePage;
629
 
630
									if ( donePage <= 0 )
631
										break;
632
								}
633
								else
634
								{
223 cycrow 635
									int pos = line.findPos(L"t id=\"");
1 cycrow 636
									if ( pos != -1 )
637
									{
223 cycrow 638
										int endpos = line.findPos(L"\"", pos + 6);
1 cycrow 639
										if ( endpos != -1 )
640
										{
223 cycrow 641
											Utils::WString check = line.mid(pos + 7, endpos - pos - 6);
1 cycrow 642
 
223 cycrow 643
											Utils::WString data;
644
											int pos = line.findPos(L">", endpos);
1 cycrow 645
											if ( pos != -1 )
646
											{
223 cycrow 647
												endpos = line.findPos(L"</", pos);
1 cycrow 648
												if ( endpos != -1 )
182 cycrow 649
													data = line.mid(pos + 2, endpos - pos - 1);
1 cycrow 650
											}
223 cycrow 651
											Utils::WString find = textList->findData(check);
652
											if (find)
653
												textList->remove(find);
1 cycrow 654
											else
223 cycrow 655
												textList->pushBack(data, check);
1 cycrow 656
										}
657
									}
658
								}
659
							}
660
						}
661
 
82 cycrow 662
						Open.close();
1 cycrow 663
					}
664
				}
665
 
666
				tcText = true;
667
			}
668
		}
669
 
670
		void LoadGameDirectory()
671
		{
672
			CPackages p;
213 cycrow 673
			p.startup(L".", L".", L".");
1 cycrow 674
 
197 cycrow 675
			for ( int i = 1; i < p.GetGameExe()->numGames(); i++ )
1 cycrow 676
			{
197 cycrow 677
				SGameExe *exe = p.GetGameExe()->game(i);
223 cycrow 678
				if ( !m_pDirList->containsData(Utils::WString::Number(i)) )
1 cycrow 679
				{
125 cycrow 680
					if ( MessageBox::Show(this, "You have no directories set for " + _US(exe->sName) + "\n\nWould you like to set it now?", "Game Directory", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
1 cycrow 681
					{
682
						FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
125 cycrow 683
						fbd->Description = "Select the path for " + _US(exe->sName);
1 cycrow 684
						if ( fbd->ShowDialog(this) == System::Windows::Forms::DialogResult::OK )
685
						{
224 cycrow 686
							CDirIO Dir(_WS(fbd->SelectedPath));
125 cycrow 687
							if ( !Dir.exists(exe->sExe) )
191 cycrow 688
								MessageBox::Show(this, "Unable to find " + _US(exe->sExe) + " in " + fbd->SelectedPath, "Game Directory", MessageBoxButtons::OK, MessageBoxIcon::Warning);
1 cycrow 689
							else
223 cycrow 690
								m_pDirList->pushBack(_WS(fbd->SelectedPath), Utils::WString::Number(i));
1 cycrow 691
						}
692
					}
693
					else
223 cycrow 694
						m_pDirList->pushBack(L"-1", Utils::WString::Number(i));
1 cycrow 695
				}
696
			}
697
 
223 cycrow 698
			if ( !m_pDirList->empty() )
1 cycrow 699
			{
700
				if ( MessageBox::Show(this, "Would you like to load the game data?", "Load Game Data", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
701
					this->LoadGameData();
702
			}
703
 
704
			this->UpdateGames();
705
		}
706
 
707
		void CloseDialog()
708
		{
709
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
213 cycrow 710
			CFileIO Config(_WS(mydoc) + L"/Egosoft/xspconvert.dat");
223 cycrow 711
			std::vector<Utils::WString> lines;
712
			for(auto itr = m_pDirList->begin(); itr != m_pDirList->end(); itr++)
713
				lines.push_back(L"Dir:" + (*itr)->data + L" " + (*itr)->str);
1 cycrow 714
			if ( m_bReadText )
223 cycrow 715
				lines.push_back(L"ReadText");
716
			Config.writeFile(lines);
1 cycrow 717
		}
718
 
719
		void CheckListChanged()
720
		{
721
			if ( m_bDontUpdate )
722
				return;
723
 
724
			if ( m_bDontChange )
725
				return;
726
 
727
			if ( m_pLoadedShip )
728
				m_bChanged = true;
729
 
730
			this->UpdateTitle();
731
		}
732
 
733
		int GetMask(CheckedListBox ^list)
734
		{
735
			int oldMask = 0;
736
			// First show the index and check state of all selected items.
737
			IEnumerator^ myEnum1 = list->CheckedIndices->GetEnumerator();
738
			while ( myEnum1->MoveNext() )
739
			{
740
				int indexChecked =  *safe_cast<int^>(myEnum1->Current);
741
				oldMask |= (1 << indexChecked);
742
			}
743
 
744
			return oldMask;
745
		}
746
 
747
		void SaveMasks()
748
		{
749
			if ( m_pLoadedShip )
750
			{
751
				if ( m_iOldGame != -1 )
752
				{
753
					m_pLoadedShip->SetLaserMask(m_iOldGame, m_iLaserMask);
754
					m_pLoadedShip->SetMissileMask(m_iOldGame, m_iMissileMask);
755
				}
756
				if ( m_pCockpit )
216 cycrow 757
					m_pLoadedShip->addCockpit(m_pCockpit->sCockpit, (m_iOldGame == -1) ? (this->ComboGame->SelectedIndex + 2) : m_iOldGame, this->GetMask(this->CockpitWeapons));
1 cycrow 758
			}
759
		}
760
 
761
		void ChangeGame()
762
		{
763
			if ( !m_pLoadedShip )
764
				return;
765
 
50 cycrow 766
			bool oldChanged = m_pLoadedShip->hasChanged();
1 cycrow 767
			m_bDontUpdate = true;
768
			// save old mask
769
			if ( !m_bLoading )
770
				this->SaveMasks();
771
 
772
			m_iOldGame = this->ComboGame->SelectedIndex + 2;
773
 
774
			this->UpdateNames();
775
 
776
			int mask = m_pLoadedShip->GetLaserMask(this->ComboGame->SelectedIndex + 2, true);
777
			for ( int i = 0; i < this->WeaponList->Items->Count; i++ )
778
				this->WeaponList->SetItemChecked(i, (mask & (1 << i)) ? true : false);
779
			m_iLaserMask = m_iLoadedLaserMask = mask;
780
 
781
			mask = m_pLoadedShip->GetMissileMask(this->ComboGame->SelectedIndex + 2, true);
782
			for ( int i = 0; i < this->MissileList->Items->Count; i++ )
783
				this->MissileList->SetItemChecked(i, (mask & (1 << i)) ? true : false);
784
			m_iMissileMask = m_iLoadedMissileMask = mask;
785
 
786
			if ( this->ComboCockpits->Items->Count )
787
			{
788
				if ( this->ComboCockpits->SelectedIndex < 0 )
789
					this->ComboCockpits->SelectedIndex = 0;
790
				else
791
					this->UpdateCockpitList();
792
			}
793
 
50 cycrow 794
			m_pLoadedShip->adjustChanged(oldChanged);
1 cycrow 795
 
796
			m_bDontUpdate = false;
797
 
798
			this->UpdateTitle();
799
		}
800
 
801
		void Event_RemoveDirectory(System::Object ^sender, System::EventArgs ^E)
802
		{
803
			System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
804
			if ( item )
805
			{
223 cycrow 806
				Utils::WString game = _WS(cli::safe_cast<System::String ^>(item->Tag));
807
				game = game.token(L" ", 1);
808
				Utils::WString find = m_pDirList->findData(game);
809
				if(find)
1 cycrow 810
				{
223 cycrow 811
					m_pDirList->remove(find);
812
					m_pDirList->pushBack(L"-1", game);
1 cycrow 813
					this->UpdateGames();
814
				}
815
			}
816
		}
817
 
818
		void Event_ChangeDirectory(System::Object ^sender, System::EventArgs ^E)
819
		{
820
			System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
821
			if ( item )
822
			{
224 cycrow 823
				Utils::WString tag = _WS(cli::safe_cast<System::String ^>(item->Tag));
223 cycrow 824
				Utils::WString game = tag.token(L" ", 1);
825
				if ( m_pDirList->containsData(game) )
1 cycrow 826
				{
827
					FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
223 cycrow 828
					fbd->Description = "Select the path for " + _US(tag.tokens(L" ", 2));
1 cycrow 829
					if ( fbd->ShowDialog() == System::Windows::Forms::DialogResult::OK )
830
					{
223 cycrow 831
						Utils::WString data = m_pDirList->findData(game);
832
						m_pDirList->remove(data);
833
						m_pDirList->pushBack(_WS(fbd->SelectedPath), game);
1 cycrow 834
						this->UpdateGames();
835
					}					
836
				}
837
			}
838
		}
839
 
840
		void UpdateCockpitList()
841
		{
842
			if ( !m_pLoadedShip )
843
				return;
844
 
845
			m_bDontChange = true;
846
 
847
			if ( !m_bDontUpdate && m_pCockpit )
216 cycrow 848
				m_pLoadedShip->addCockpit(m_pCockpit->sCockpit, (m_iOldGame == -1) ? (this->ComboGame->SelectedIndex + 2) : m_iOldGame, this->GetMask(this->CockpitWeapons));
1 cycrow 849
 
850
			m_pCockpit = NULL;
851
 
852
			// find the cockpit pointer
853
			m_pCockpit = m_pLoadedShip->GetCockpits()->Get(this->ComboCockpits->SelectedIndex);
854
 
855
			int mask = 0;
856
			if ( m_pCockpit )
857
			{
216 cycrow 858
				mask = m_pCockpit->sCockpit.token(L";", 9);
1 cycrow 859
				for ( SWeaponMask *wm = m_pCockpit->lWeaponMask.First(); wm; wm = m_pCockpit->lWeaponMask.Next() )
860
				{
861
					if ( wm->iGame == (this->ComboGame->SelectedIndex + 2) )
862
					{
863
						mask = wm->iMask;
864
						break;
865
					}
866
				}
867
			}
868
 
869
			for ( int i = 0; i < this->CockpitWeapons->Items->Count; i++ )
870
				this->CockpitWeapons->SetItemChecked(i, (mask & (1 << i)) ? true : false);
871
 
872
			m_bDontChange = false;
873
		}
874
 
875
 
876
		void InitializeComponent(void)
877
		{
878
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
879
			this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
880
			this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
881
			this->openToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
882
			this->saveToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
883
			this->saveAsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
884
			this->settingsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
885
			this->gamesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
886
			this->loadGameTextToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
887
			this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
888
			this->updateGameDataToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
889
			this->panel1 = (gcnew System::Windows::Forms::Panel());
890
			this->ButExit = (gcnew System::Windows::Forms::Button());
891
			this->PanelMain = (gcnew System::Windows::Forms::Panel());
892
			this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
893
			this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
894
			this->WeaponList = (gcnew System::Windows::Forms::CheckedListBox());
895
			this->tabPage2 = (gcnew System::Windows::Forms::TabPage());
896
			this->MissileList = (gcnew System::Windows::Forms::CheckedListBox());
897
			this->tabPage3 = (gcnew System::Windows::Forms::TabPage());
898
			this->CockpitWeapons = (gcnew System::Windows::Forms::CheckedListBox());
899
			this->ComboCockpits = (gcnew System::Windows::Forms::ComboBox());
900
			this->panel2 = (gcnew System::Windows::Forms::Panel());
901
			this->ComboGame = (gcnew System::Windows::Forms::ComboBox());
902
			this->label1 = (gcnew System::Windows::Forms::Label());
903
			this->PanelNotLoaded = (gcnew System::Windows::Forms::Panel());
904
			this->LabelNotLoaded = (gcnew System::Windows::Forms::Label());
905
			this->menuStrip1->SuspendLayout();
906
			this->panel1->SuspendLayout();
907
			this->PanelMain->SuspendLayout();
908
			this->tabControl1->SuspendLayout();
909
			this->tabPage1->SuspendLayout();
910
			this->tabPage2->SuspendLayout();
911
			this->tabPage3->SuspendLayout();
912
			this->panel2->SuspendLayout();
913
			this->PanelNotLoaded->SuspendLayout();
914
			this->SuspendLayout();
915
			// 
916
			// menuStrip1
917
			// 
918
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->fileToolStripMenuItem, 
919
				this->settingsToolStripMenuItem});
920
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
921
			this->menuStrip1->Name = L"menuStrip1";
922
			this->menuStrip1->Size = System::Drawing::Size(416, 24);
923
			this->menuStrip1->TabIndex = 0;
924
			this->menuStrip1->Text = L"menuStrip1";
925
			// 
926
			// fileToolStripMenuItem
927
			// 
928
			this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->openToolStripMenuItem, 
929
				this->saveToolStripMenuItem, this->saveAsToolStripMenuItem});
930
			this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
931
			this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20);
932
			this->fileToolStripMenuItem->Text = L"&File";
933
			// 
934
			// openToolStripMenuItem
935
			// 
936
			this->openToolStripMenuItem->Name = L"openToolStripMenuItem";
937
			this->openToolStripMenuItem->Size = System::Drawing::Size(114, 22);
938
			this->openToolStripMenuItem->Text = L"&Open";
939
			this->openToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::openToolStripMenuItem_Click);
940
			// 
941
			// saveToolStripMenuItem
942
			// 
943
			this->saveToolStripMenuItem->Name = L"saveToolStripMenuItem";
944
			this->saveToolStripMenuItem->Size = System::Drawing::Size(114, 22);
945
			this->saveToolStripMenuItem->Text = L"&Save";
946
			this->saveToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveToolStripMenuItem_Click);
947
			// 
948
			// saveAsToolStripMenuItem
949
			// 
950
			this->saveAsToolStripMenuItem->Name = L"saveAsToolStripMenuItem";
951
			this->saveAsToolStripMenuItem->Size = System::Drawing::Size(114, 22);
952
			this->saveAsToolStripMenuItem->Text = L"Save &As";
953
			this->saveAsToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveAsToolStripMenuItem_Click);
954
			// 
955
			// settingsToolStripMenuItem
956
			// 
957
			this->settingsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {this->gamesToolStripMenuItem, 
958
				this->loadGameTextToolStripMenuItem, this->toolStripSeparator1, this->updateGameDataToolStripMenuItem});
959
			this->settingsToolStripMenuItem->Name = L"settingsToolStripMenuItem";
960
			this->settingsToolStripMenuItem->Size = System::Drawing::Size(61, 20);
961
			this->settingsToolStripMenuItem->Text = L"Settings";
962
			// 
963
			// gamesToolStripMenuItem
964
			// 
965
			this->gamesToolStripMenuItem->Name = L"gamesToolStripMenuItem";
966
			this->gamesToolStripMenuItem->Size = System::Drawing::Size(173, 22);
967
			this->gamesToolStripMenuItem->Text = L"Games";
968
			// 
969
			// loadGameTextToolStripMenuItem
970
			// 
971
			this->loadGameTextToolStripMenuItem->Name = L"loadGameTextToolStripMenuItem";
972
			this->loadGameTextToolStripMenuItem->Size = System::Drawing::Size(173, 22);
973
			this->loadGameTextToolStripMenuItem->Text = L"Load Game Text";
974
			this->loadGameTextToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::loadGameTextToolStripMenuItem_Click);
975
			// 
976
			// toolStripSeparator1
977
			// 
978
			this->toolStripSeparator1->Name = L"toolStripSeparator1";
979
			this->toolStripSeparator1->Size = System::Drawing::Size(170, 6);
980
			// 
981
			// updateGameDataToolStripMenuItem
982
			// 
983
			this->updateGameDataToolStripMenuItem->Name = L"updateGameDataToolStripMenuItem";
984
			this->updateGameDataToolStripMenuItem->Size = System::Drawing::Size(173, 22);
985
			this->updateGameDataToolStripMenuItem->Text = L"Update Game Data";
986
			this->updateGameDataToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::updateGameDataToolStripMenuItem_Click);
987
			// 
988
			// panel1
989
			// 
990
			this->panel1->Controls->Add(this->ButExit);
991
			this->panel1->Dock = System::Windows::Forms::DockStyle::Bottom;
992
			this->panel1->Location = System::Drawing::Point(0, 376);
993
			this->panel1->Name = L"panel1";
994
			this->panel1->Size = System::Drawing::Size(416, 33);
995
			this->panel1->TabIndex = 1;
996
			// 
997
			// ButExit
998
			// 
999
			this->ButExit->DialogResult = System::Windows::Forms::DialogResult::Cancel;
1000
			this->ButExit->Dock = System::Windows::Forms::DockStyle::Right;
1001
			this->ButExit->Location = System::Drawing::Point(303, 0);
1002
			this->ButExit->Name = L"ButExit";
1003
			this->ButExit->Size = System::Drawing::Size(113, 33);
1004
			this->ButExit->TabIndex = 0;
1005
			this->ButExit->Text = L"Exit";
1006
			this->ButExit->UseVisualStyleBackColor = true;
1007
			this->ButExit->Click += gcnew System::EventHandler(this, &Form1::ButExit_Click);
1008
			// 
1009
			// PanelMain
1010
			// 
1011
			this->PanelMain->Controls->Add(this->tabControl1);
1012
			this->PanelMain->Controls->Add(this->panel2);
1013
			this->PanelMain->Dock = System::Windows::Forms::DockStyle::Fill;
1014
			this->PanelMain->Location = System::Drawing::Point(0, 24);
1015
			this->PanelMain->Name = L"PanelMain";
1016
			this->PanelMain->Size = System::Drawing::Size(416, 352);
1017
			this->PanelMain->TabIndex = 2;
1018
			// 
1019
			// tabControl1
1020
			// 
1021
			this->tabControl1->Controls->Add(this->tabPage1);
1022
			this->tabControl1->Controls->Add(this->tabPage2);
1023
			this->tabControl1->Controls->Add(this->tabPage3);
1024
			this->tabControl1->Dock = System::Windows::Forms::DockStyle::Fill;
1025
			this->tabControl1->Location = System::Drawing::Point(0, 22);
1026
			this->tabControl1->Name = L"tabControl1";
1027
			this->tabControl1->SelectedIndex = 0;
1028
			this->tabControl1->Size = System::Drawing::Size(416, 330);
1029
			this->tabControl1->TabIndex = 2;
1030
			// 
1031
			// tabPage1
1032
			// 
1033
			this->tabPage1->Controls->Add(this->WeaponList);
1034
			this->tabPage1->Location = System::Drawing::Point(4, 22);
1035
			this->tabPage1->Name = L"tabPage1";
1036
			this->tabPage1->Padding = System::Windows::Forms::Padding(3);
1037
			this->tabPage1->Size = System::Drawing::Size(408, 304);
1038
			this->tabPage1->TabIndex = 0;
1039
			this->tabPage1->Text = L"Lasers";
1040
			this->tabPage1->UseVisualStyleBackColor = true;
1041
			// 
1042
			// WeaponList
1043
			// 
1044
			this->WeaponList->CheckOnClick = true;
1045
			this->WeaponList->Dock = System::Windows::Forms::DockStyle::Fill;
1046
			this->WeaponList->FormattingEnabled = true;
1047
			this->WeaponList->HorizontalScrollbar = true;
1048
			this->WeaponList->Location = System::Drawing::Point(3, 3);
1049
			this->WeaponList->Name = L"WeaponList";
1050
			this->WeaponList->Size = System::Drawing::Size(402, 289);
1051
			this->WeaponList->TabIndex = 3;
1052
			this->WeaponList->ItemCheck += gcnew System::Windows::Forms::ItemCheckEventHandler(this, &Form1::WeaponListEvent_Changed);
1053
			// 
1054
			// tabPage2
1055
			// 
1056
			this->tabPage2->Controls->Add(this->MissileList);
1057
			this->tabPage2->Location = System::Drawing::Point(4, 22);
1058
			this->tabPage2->Name = L"tabPage2";
1059
			this->tabPage2->Padding = System::Windows::Forms::Padding(3);
1060
			this->tabPage2->Size = System::Drawing::Size(408, 304);
1061
			this->tabPage2->TabIndex = 1;
1062
			this->tabPage2->Text = L"Missiles";
1063
			this->tabPage2->UseVisualStyleBackColor = true;
1064
			// 
1065
			// MissileList
1066
			// 
1067
			this->MissileList->Dock = System::Windows::Forms::DockStyle::Fill;
1068
			this->MissileList->FormattingEnabled = true;
1069
			this->MissileList->HorizontalScrollbar = true;
1070
			this->MissileList->Location = System::Drawing::Point(3, 3);
1071
			this->MissileList->Name = L"MissileList";
1072
			this->MissileList->Size = System::Drawing::Size(402, 289);
1073
			this->MissileList->TabIndex = 4;
1074
			this->MissileList->ItemCheck += gcnew System::Windows::Forms::ItemCheckEventHandler(this, &Form1::MissileListEvent_Changed);
1075
			// 
1076
			// tabPage3
1077
			// 
1078
			this->tabPage3->Controls->Add(this->CockpitWeapons);
1079
			this->tabPage3->Controls->Add(this->ComboCockpits);
1080
			this->tabPage3->Location = System::Drawing::Point(4, 22);
1081
			this->tabPage3->Name = L"tabPage3";
1082
			this->tabPage3->Padding = System::Windows::Forms::Padding(3);
1083
			this->tabPage3->Size = System::Drawing::Size(408, 304);
1084
			this->tabPage3->TabIndex = 2;
1085
			this->tabPage3->Text = L"Cockpits";
1086
			this->tabPage3->UseVisualStyleBackColor = true;
1087
			// 
1088
			// CockpitWeapons
1089
			// 
1090
			this->CockpitWeapons->CheckOnClick = true;
1091
			this->CockpitWeapons->Dock = System::Windows::Forms::DockStyle::Fill;
1092
			this->CockpitWeapons->FormattingEnabled = true;
1093
			this->CockpitWeapons->HorizontalScrollbar = true;
1094
			this->CockpitWeapons->Location = System::Drawing::Point(3, 24);
1095
			this->CockpitWeapons->Name = L"CockpitWeapons";
1096
			this->CockpitWeapons->Size = System::Drawing::Size(402, 274);
1097
			this->CockpitWeapons->TabIndex = 4;
1098
			// 
1099
			// ComboCockpits
1100
			// 
1101
			this->ComboCockpits->Dock = System::Windows::Forms::DockStyle::Top;
1102
			this->ComboCockpits->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
1103
			this->ComboCockpits->FormattingEnabled = true;
1104
			this->ComboCockpits->Location = System::Drawing::Point(3, 3);
1105
			this->ComboCockpits->Name = L"ComboCockpits";
1106
			this->ComboCockpits->Size = System::Drawing::Size(402, 21);
1107
			this->ComboCockpits->TabIndex = 5;
1108
			this->ComboCockpits->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::ComboCockpits_SelectedIndexChanged);
1109
			// 
1110
			// panel2
1111
			// 
1112
			this->panel2->Controls->Add(this->ComboGame);
1113
			this->panel2->Controls->Add(this->label1);
1114
			this->panel2->Dock = System::Windows::Forms::DockStyle::Top;
1115
			this->panel2->Location = System::Drawing::Point(0, 0);
1116
			this->panel2->Name = L"panel2";
1117
			this->panel2->Size = System::Drawing::Size(416, 22);
1118
			this->panel2->TabIndex = 2;
1119
			// 
1120
			// ComboGame
1121
			// 
1122
			this->ComboGame->Dock = System::Windows::Forms::DockStyle::Fill;
1123
			this->ComboGame->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
1124
			this->ComboGame->FormattingEnabled = true;
1125
			this->ComboGame->Location = System::Drawing::Point(188, 0);
1126
			this->ComboGame->Name = L"ComboGame";
1127
			this->ComboGame->Size = System::Drawing::Size(228, 21);
1128
			this->ComboGame->TabIndex = 0;
1129
			this->ComboGame->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::ComboGame_SelectedIndexChanged);
1130
			// 
1131
			// label1
1132
			// 
1133
			this->label1->Dock = System::Windows::Forms::DockStyle::Left;
1134
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
1135
				static_cast<System::Byte>(0)));
1136
			this->label1->Location = System::Drawing::Point(0, 0);
1137
			this->label1->Name = L"label1";
1138
			this->label1->Size = System::Drawing::Size(188, 22);
1139
			this->label1->TabIndex = 1;
1140
			this->label1->Text = L"X-Universe Game:";
1141
			this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft;
1142
			// 
1143
			// PanelNotLoaded
1144
			// 
1145
			this->PanelNotLoaded->Controls->Add(this->LabelNotLoaded);
1146
			this->PanelNotLoaded->Dock = System::Windows::Forms::DockStyle::Fill;
1147
			this->PanelNotLoaded->Location = System::Drawing::Point(0, 24);
1148
			this->PanelNotLoaded->Name = L"PanelNotLoaded";
1149
			this->PanelNotLoaded->Size = System::Drawing::Size(416, 352);
1150
			this->PanelNotLoaded->TabIndex = 3;
1151
			// 
1152
			// LabelNotLoaded
1153
			// 
1154
			this->LabelNotLoaded->Dock = System::Windows::Forms::DockStyle::Fill;
1155
			this->LabelNotLoaded->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
1156
				static_cast<System::Byte>(0)));
1157
			this->LabelNotLoaded->Location = System::Drawing::Point(0, 0);
1158
			this->LabelNotLoaded->Name = L"LabelNotLoaded";
1159
			this->LabelNotLoaded->Size = System::Drawing::Size(416, 352);
1160
			this->LabelNotLoaded->TabIndex = 0;
1161
			this->LabelNotLoaded->Text = L"No ship file is currently loaded";
1162
			this->LabelNotLoaded->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
1163
			// 
1164
			// Form1
1165
			// 
1166
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
1167
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
1168
			this->CancelButton = this->ButExit;
1169
			this->ClientSize = System::Drawing::Size(416, 409);
1170
			this->Controls->Add(this->PanelMain);
1171
			this->Controls->Add(this->PanelNotLoaded);
1172
			this->Controls->Add(this->panel1);
1173
			this->Controls->Add(this->menuStrip1);
1174
			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
1175
			this->MainMenuStrip = this->menuStrip1;
1176
			this->Name = L"Form1";
1177
			this->Text = L"XSP Ship Convertor";
1178
			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
1179
			this->menuStrip1->ResumeLayout(false);
1180
			this->menuStrip1->PerformLayout();
1181
			this->panel1->ResumeLayout(false);
1182
			this->PanelMain->ResumeLayout(false);
1183
			this->tabControl1->ResumeLayout(false);
1184
			this->tabPage1->ResumeLayout(false);
1185
			this->tabPage2->ResumeLayout(false);
1186
			this->tabPage3->ResumeLayout(false);
1187
			this->panel2->ResumeLayout(false);
1188
			this->PanelNotLoaded->ResumeLayout(false);
1189
			this->ResumeLayout(false);
1190
			this->PerformLayout();
1191
 
1192
		}
1193
#pragma endregion
1194
private: System::Void openToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
1195
			 this->OpenFile();
1196
		 }
1197
private: System::Void ButExit_Click(System::Object^  sender, System::EventArgs^  e) {
1198
			 this->Close();
1199
		 }
1200
private: System::Void saveToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
1201
			 this->SaveShip();
1202
		 }
1203
private: System::Void ComboGame_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
1204
			 this->ChangeGame();
1205
		 }
1206
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
1207
			 this->LoadGameDirectory();
1208
 
1209
			 if ( m_sOpenFile )
1210
				this->OpenFile(m_sOpenFile);
1211
		 }
1212
private: void CloseEvent(System::Object ^Sender, System::EventArgs ^E) {
1213
			 this->CheckSave();
1214
			 this->CloseDialog();
1215
		 }
1216
private: System::Void updateGameDataToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
1217
			 this->LoadGameData();
1218
		 }
1219
private: System::Void loadGameTextToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
1220
			 m_bReadText = !m_bReadText;
1221
			 this->loadGameTextToolStripMenuItem->Checked = m_bReadText;
1222
		 }
1223
private: System::Void WeaponListEvent_Changed(System::Object^  sender, ItemCheckEventArgs^  e) {
1224
			 if ( !m_bLoading )
1225
			 {
1226
				 int index = (1 << e->Index);
1227
				 if ( e->NewValue == CheckState::Checked )
1228
					 m_iLaserMask |= index;
1229
				 else if ( e->NewValue == CheckState::Unchecked )
1230
					 m_iLaserMask &= ~(index);
1231
 
1232
				this->CheckListChanged();
1233
			 }
1234
		 }
1235
private: System::Void MissileListEvent_Changed(System::Object^  sender, ItemCheckEventArgs^  e) {
1236
			 if ( !m_bLoading )
1237
			 {
1238
				 int index = (1 << e->Index);
1239
				 if ( e->NewValue == CheckState::Checked )
1240
					 m_iMissileMask |= index;
1241
				 else if ( e->NewValue == CheckState::Unchecked )
1242
					 m_iMissileMask &= ~(index);
1243
 
1244
				this->CheckListChanged();
1245
			 }
1246
		 }
1247
private: System::Void Event_Changed(System::Object^  sender, ItemCheckEventArgs^  e) {
1248
			 if ( !m_bLoading )
1249
			 {
1250
				this->CheckListChanged();
1251
			 }
1252
		 }
1253
private: System::Void saveAsToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
1254
			 this->SaveShipAs();
1255
		 }
1256
private: System::Void ComboCockpits_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
1257
			 this->UpdateCockpitList();
1258
		 }
1259
};
1260
}
1261