Subversion Repositories spk

Rev

Rev 218 | Rev 224 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 218 Rev 223
Line 37... Line 37...
37
			m_bDontChange = false;
37
			m_bDontChange = false;
38
			m_bDontUpdate = false;
38
			m_bDontUpdate = false;
39
			m_bChanged = false;
39
			m_bChanged = false;
40
			m_bReadText = false;
40
			m_bReadText = false;
41
			m_pLoadedShip = NULL;
41
			m_pLoadedShip = NULL;
42
			m_pDirList = new CyStringList;
42
			m_pDirList = new Utils::WStringList;
43
			m_pTextList = new CLinkList<CyStringList>;
43
			m_pTextList = new CLinkList<Utils::WStringList>;
44
			m_pLaserList = new CLinkList<CyStringList>;
44
			m_pLaserList = new CLinkList<Utils::WStringList>;
45
			m_pMissileList = new CLinkList<CyStringList>;
45
			m_pMissileList = new CLinkList<Utils::WStringList>;
46
			m_pCockpit = NULL;
46
			m_pCockpit = NULL;
47
			this->PanelMain->Hide();
47
			this->PanelMain->Hide();
48
			this->PanelNotLoaded->Show();
48
			this->PanelNotLoaded->Show();
49
 
49
 
50
			m_iOldGame = -1;
50
			m_iOldGame = -1;
Line 90... Line 90...
90
		bool		m_bLoading;
90
		bool		m_bLoading;
91
		bool		m_bDontUpdate;
91
		bool		m_bDontUpdate;
92
		bool		m_bChanged;
92
		bool		m_bChanged;
93
		bool		m_bReadText;
93
		bool		m_bReadText;
94
		bool		m_bDontChange;
94
		bool		m_bDontChange;
95
		CyStringList *m_pDirList;
95
		Utils::WStringList *m_pDirList;
96
		CLinkList<CyStringList> *m_pTextList;
96
		CLinkList<Utils::WStringList> *m_pTextList;
97
		CLinkList<CyStringList> *m_pLaserList;
97
		CLinkList<Utils::WStringList> *m_pLaserList;
98
		CLinkList<CyStringList> *m_pMissileList;
98
		CLinkList<Utils::WStringList> *m_pMissileList;
99
		CXspFile	*m_pLoadedShip;
99
		CXspFile	*m_pLoadedShip;
100
		int			 m_iOldGame;
100
		int			 m_iOldGame;
101
		array<System::Windows::Forms::ToolStripMenuItem^> ^m_aTools;
101
		array<System::Windows::Forms::ToolStripMenuItem^> ^m_aTools;
102
		System::String ^m_sOpenFile;
102
		System::String ^m_sOpenFile;
103
		SCockpit	*m_pCockpit;
103
		SCockpit	*m_pCockpit;
Line 147... Line 147...
147
			this->CockpitWeapons->ItemCheck += gcnew ItemCheckEventHandler(this, &Form1::Event_Changed);
147
			this->CockpitWeapons->ItemCheck += gcnew ItemCheckEventHandler(this, &Form1::Event_Changed);
148
 
148
 
149
			// read data file
149
			// read data file
150
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
150
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
151
			CFileIO Config;
151
			CFileIO Config;
152
			if ( Config.open(_S(mydoc) + "/Egosoft/xspconvert.dat") )
152
			if ( Config.open(_WS(mydoc) + L"/Egosoft/xspconvert.dat") )
153
			{
153
			{
154
				std::vector<Utils::String> *lines = Config.readLines();
154
				std::vector<Utils::WString> lines;
155
				if ( lines )
155
				if(Config.readLines(lines))
156
				{
156
				{
157
					for ( int i = 0; i < (int)lines->size(); i++ )
157
					for (size_t i = 0; i < lines.size(); i++ )
158
					{
158
					{
159
						Utils::String line(lines->at(i));
159
						Utils::WString line(lines.at(i));
160
						Utils::String start = line.token(":", 1).toLower();
160
						Utils::WString start = line.token(L":", 1).toLower();
161
						Utils::String rest = line.tokens(":", 2).removeFirstSpace();
161
						Utils::WString rest = line.tokens(L":", 2).removeFirstSpace();
162
						if ( start.Compare("Dir") )
162
						if ( start.Compare(L"Dir") )
163
						{
163
						{
164
							Utils::String game = rest.token(" ", 1);
164
							Utils::WString game = rest.token(L" ", 1);
165
							Utils::String dir = rest.tokens(" ", 2);
165
							Utils::WString dir = rest.tokens(L" ", 2);
166
							SStringList *str = m_pDirList->FindData(game);
166
							Utils::WString find = m_pDirList->findData(game);
167
							if ( str )
167
							if (!find.empty())
168
								str->str = dir;
168
								m_pDirList->remove(find);
169
							else
-
 
170
								m_pDirList->PushBack(CyString(dir), CyString(game));
169
							m_pDirList->pushBack(dir, game);
171
						}
170
						}
172
						else if ( line.Compare("ReadText") )
171
						else if ( line.Compare(L"ReadText") )
173
							m_bReadText = true;
172
							m_bReadText = true;
174
					}
173
					}
175
				}
174
				}
176
			}
175
			}
177
 
176
 
Line 189... Line 188...
189
			p.startup(L".", L".", L".");
188
			p.startup(L".", L".", L".");
190
			// start at 1 to skip X2
189
			// start at 1 to skip X2
191
			for ( int i = 1; i < p.GetGameExe()->numGames(); i++ )
190
			for ( int i = 1; i < p.GetGameExe()->numGames(); i++ )
192
			{
191
			{
193
				bool added = false;
192
				bool added = false;
194
				if ( m_pDirList->;FindData(CyString::Number(i)) )
193
				Utils::WString find = m_pDirList->;findData(Utils::WString::Number(i));
-
 
194
				if (!find.empty())
195
				{
195
				{
196
					if ( m_pDirList->FindData(CyString::Number(i))->str != ";-1" )
196
					if(find != L";-1")
197
						added = true;
197
						added = true;
198
				}
198
				}
199
 
199
 
200
				SGameExe *exe = p.GetGameExe()->game(i);
200
				SGameExe *exe = p.GetGameExe()->game(i);
201
				this->ComboGame->Items->Add(_US(exe->sName));
201
				this->ComboGame->Items->Add(_US(exe->sName));
202
				System::Windows::Forms::ToolStripMenuItem ^newMenu = gcnew System::Windows::Forms::ToolStripMenuItem;
202
				System::Windows::Forms::ToolStripMenuItem ^newMenu = gcnew System::Windows::Forms::ToolStripMenuItem;
203
				newMenu->Text = _US(exe->sName);
203
				newMenu->Text = _US(exe->sName);
204
				this->gamesToolStripMenuItem->DropDownItems->Add(newMenu);
204
				this->gamesToolStripMenuItem->DropDownItems->Add(newMenu);
205
				System::Windows::Forms::ToolStripMenuItem ^newMenuDir = gcnew System::Windows::Forms::ToolStripMenuItem;
205
				System::Windows::Forms::ToolStripMenuItem ^newMenuDir = gcnew System::Windows::Forms::ToolStripMenuItem;
206
				if ( added )
206
				if ( added )
207
					newMenuDir->Text = _US(m_pDirList->FindData(Utils::String::Number(i))->str.ToString());
207
					newMenuDir->Text = _US(m_pDirList->findData(Utils::WString::Number(i)));
208
				else
208
				else
209
					newMenuDir->Text = "No Directory";
209
					newMenuDir->Text = "No Directory";
210
				newMenuDir->Enabled = false;
210
				newMenuDir->Enabled = false;
211
				newMenu->DropDownItems->Add(newMenuDir);
211
				newMenu->DropDownItems->Add(newMenuDir);
212
				newMenu->DropDownItems->Add(gcnew System::Windows::Forms::ToolStripSeparator);
212
				newMenu->DropDownItems->Add(gcnew System::Windows::Forms::ToolStripSeparator);
Line 280... Line 280...
280
			}
280
			}
281
 
281
 
282
			this->UpdateTitle();
282
			this->UpdateTitle();
283
		}
283
		}
284
 
284
 
285
		CyString GetObjectString(int desc, CyString idText)
285
		Utils::WString GetObjectString(int desc, const Utils::WString &idText)
286
		{
286
		{
287
			if ( m_bReadText )
287
			if ( m_bReadText )
288
			{
288
			{
289
				if ( this->ComboGame->SelectedIndex < m_pMissileList->size() )
289
				if ( this->ComboGame->SelectedIndex < m_pMissileList->size() )
290
				{
290
				{
291
					CyStringList *textList = m_pTextList->Get(this->ComboGame->SelectedIndex);
291
					Utils::WStringList *textList = m_pTextList->Get(this->ComboGame->SelectedIndex);
292
					if ( textList )
292
					if ( textList )
293
					{
293
					{
294
						SStringList *str = textList->FindData(CyString::Number(desc));
294
						Utils::WString str = textList->findData(Utils::WString::Number(desc));
295
						if ( str )
295
						if (str)
296
						{
296
						{
297
							// perform recursive lookup
297
							// perform recursive lookup
298
							CyString s = str->str;
-
 
299
							while (s.IsIn("{17,") && s.IsIn("}"))
298
							while (str.contains(L"{17,") && str.contains(L"}"))
300
							{
299
							{
301
								int pos = s.FindPos("{17,");
300
								int pos = str.findPos(L"{17,");
302
								pos += 4;
301
								pos += 4;
303
								CyString check = s.Right(-pos);
302
								Utils::WString check = str.right(-pos);
304
								check = check.GetToken("}", 1, 1);
303
								check = check.token(L"}", 1);
305
								int num = check.ToInt();
304
								int num = check.toInt();
306
								CyString newDesc = this->GetObjectString(num, CyString("#") + check + "#");
305
								Utils::WString newDesc = this->GetObjectString(num, L"#" + check + L"#");
307
								s = s.FindReplace(CyString("{17,") + check + "}", newDesc);
306
								str = str.findReplace(L"{17," + check + L"}", newDesc);
308
							}
307
							}
309
 
308
 
310
							// remove anything in brackets
309
							// remove anything in brackets
311
							while(s.IsIn("(") && s.IsIn(")"))
310
							while(str.contains(L"(") && str.contains(L")"))
312
							{
311
							{
313
								int pos = s.FindPos("(");
312
								int pos = str.findPos(L"(");
314
								s.Erase(pos, (s.FindPos(")", pos) + 1) - pos);
313
								str.erase(pos, (str.findPos(L")", pos) + 1) - pos);
315
							}
314
							}
316
							return s;
315
							return str;
317
						}
316
						}
318
					}
317
					}
319
				}
318
				}
320
			}
319
			}
321
			return idText;
320
			return idText;
Line 327... Line 326...
327
			this->MissileList->Items->Clear();
326
			this->MissileList->Items->Clear();
328
			this->CockpitWeapons->Items->Clear();
327
			this->CockpitWeapons->Items->Clear();
329
			bool addedLaser = false;
328
			bool addedLaser = false;
330
			bool addedMissile = false;
329
			bool addedMissile = false;
331
 
330
 
332
			CyStringList missiles;
331
			Utils::WStringList missiles;
333
			if ( this->ComboGame->SelectedIndex < m_pMissileList->size() )
332
			if ( this->ComboGame->SelectedIndex < m_pMissileList->size() )
334
			{
333
			{
335
				CyStringList *missileList = m_pMissileList->Get(this->ComboGame->SelectedIndex);
334
				Utils::WStringList *missileList = m_pMissileList->Get(this->ComboGame->SelectedIndex);
336
				if ( missileList )
335
				if ( missileList )
337
				{
336
				{
338
					for ( SStringList *strNode = missileList->;Head(); strNode; strNode = strNode->next )
337
					for(auto itr = missileList->;begin(); itr != missileList->end(); itr++)
339
					{
338
					{
340
						CyString id = strNode-&gt;str.GetToken(";", 6, 6);
339
						Utils::WString id = (*itr)-&gt;str.token(L";", 6);
341
						SStringList *found = missiles.FindString(id);
340
						Utils::WStringNode* found = missiles[id];
342
						CyString str = this->GetObjectString(strNode->str.GetToken(";", 7, 7).ToInt(), strNode->str.GetToken(";", 37, 37));
341
						Utils::WString str = this->GetObjectString((*itr)->str.token(L";", 7).toInt(), (*itr)->str.token(L";", 37));
343
						if ( found )
342
						if ( found )
344
						{
343
						{
345
							found->data += ", ";
344
							found->data += L", ";
346
							found->data += str;
345
							found->data += str;
347
						}
346
						}
348
						else
347
						else
349
							missiles.PushBack(id, str);
348
							missiles.pushBack(id, str);
350
					}
349
					}
351
				}
350
				}
352
			}
351
			}
353
 
352
 
354
			CyStringList lasers;
353
			Utils::WStringList lasers;
355
			if ( this->ComboGame->SelectedIndex < m_pLaserList->size() )
354
			if ( this->ComboGame->SelectedIndex < m_pLaserList->size() )
356
			{
355
			{
357
				CyStringList *laserList = m_pLaserList->Get(this->ComboGame->SelectedIndex);
356
				Utils::WStringList *laserList = m_pLaserList->Get(this->ComboGame->SelectedIndex);
358
				if ( laserList )
357
				if ( laserList )
359
				{
358
				{
360
					for ( SStringList *strNode = laserList->Head(); strNode; strNode = strNode->next )
359
					for (auto itr = laserList->begin(); itr != laserList->end(); itr++)
361
					{
360
					{
362
						CyString id = strNode-&gt;str.GetToken(";", 6, 6);
361
						Utils::WString id = (*itr)-&gt;str.token(L";", 6);
363
						SStringList *found = lasers.FindString(id);
362
						Utils::WStringNode* found = lasers[id];
364
						CyString str = this->GetObjectString(strNode->str.GetToken(";", 7, 7).ToInt(), strNode->str.GetToken(";", 23, 23));
363
						Utils::WString str = this->GetObjectString((*itr)->str.token(L";", 7).toInt(), (*itr)->str.token(L";", 23));
365
						if ( found )
364
						if ( found )
366
						{
365
						{
367
							found->data += ", ";
366
							found->data += L", ";
368
							found->data += str;
367
							found->data += str;
369
						}
368
						}
370
						else
369
						else
371
							lasers.PushBack(id, str);
370
							lasers.pushBack(id, str);
372
					}
371
					}
373
				}
372
				}
374
			}
373
			}
375
 
374
 
376
			for ( int i = 0; i < 32; i++ )
375
			for (size_t i = 0; i < 32; i++ )
377
			{
376
			{
378
				if ( lasers.Count() > i )
377
				if ( lasers.size() > i )
379
				{
378
				{
380
					this->WeaponList->Items->Add(_US(lasers.GetAt(i)->data.ToString()));
379
					this->WeaponList->Items->Add(_US(lasers[i]->data));
381
					this->CockpitWeapons->Items->Add(_US(lasers.GetAt(i)->data.ToString()));
380
					this->CockpitWeapons->Items->Add(_US(lasers[i]->data));
382
					addedLaser = true;
381
					addedLaser = true;
383
				}
382
				}
384
 
383
 
385
				if ( missiles.Count() > i )
384
				if ( missiles.size() > i )
386
				{
385
				{
387
					this->MissileList->Items->Add(_US(missiles.GetAt(i)->data.ToString()));
386
					this->MissileList->Items->Add(_US(missiles[i]->data));
388
					addedMissile = true;
387
					addedMissile = true;
389
				}
388
				}
390
 
389
 
391
				if ( !addedLaser )
390
				if ( !addedLaser )
392
				{
391
				{
393
					this->WeaponList->Items->Add(_US(Utils::String::Number(i + 1)));
392
					this->WeaponList->Items->Add(_US(Utils::WString::Number(i + 1)));
394
					this->CockpitWeapons->Items->Add(_US(Utils::String::Number(i + 1)));
393
					this->CockpitWeapons->Items->Add(_US(Utils::WString::Number(i + 1)));
395
				}
394
				}
396
				if ( !addedMissile )
395
				if ( !addedMissile )
397
					this->MissileList->Items->Add(_US(Utils::String::Number(i + 1)));
396
					this->MissileList->Items->Add(_US(Utils::WString::Number(i + 1)));
398
			}
397
			}
399
		}
398
		}
400
 
399
 
401
		void OpenFile(System::String ^open)
400
		void OpenFile(System::String ^open)
402
		{
401
		{
Line 504... Line 503...
504
			m_pLaserList->MemoryClear();
503
			m_pLaserList->MemoryClear();
505
			m_pMissileList->MemoryClear();
504
			m_pMissileList->MemoryClear();
506
			m_pTextList->MemoryClear();
505
			m_pTextList->MemoryClear();
507
 
506
 
508
			System::String ^tempDir = System::IO::Path::GetTempPath();
507
			System::String ^tempDir = System::IO::Path::GetTempPath();
509
			Utils::String sTempDir = _S(tempDir);
508
			Utils::WString sTempDir = _WS(tempDir);
510
 
509
 
511
			CPackages p;
510
			CPackages p;
512
			bool tcText = false;
511
			bool tcText = false;
513
			for ( SStringList *strNode = m_pDirList->;Head(); strNode; strNode = strNode->next )
512
			for(auto itr = m_pDirList->;begin(); itr != m_pDirList->end(); itr++)
514
			{
513
			{
515
				CyStringList *laserList = new CyStringList;
514
				Utils::WStringList *laserList = new Utils::WStringList;
516
				m_pLaserList->push_back(laserList);
515
				m_pLaserList->push_back(laserList);
517
				CyStringList *missileList = new CyStringList;
516
				Utils::WStringList *missileList = new Utils::WStringList;
518
				m_pMissileList->push_back(missileList);
517
				m_pMissileList->push_back(missileList);
519
				CyStringList *textList = new CyStringList;
518
				Utils::WStringList *textList = new Utils::WStringList;
520
				m_pTextList->push_back(textList);
519
				m_pTextList->push_back(textList);
521
 
520
 
522
				if ( p.extractGameFile(L"types/TLaser.pck", sTempDir + L"/TLaser.txt", strNode->str.ToString()) )
521
				if ( p.extractGameFile(L"types/TLaser.pck", sTempDir + L"/TLaser.txt", (*itr)->str) )
523
				{
522
				{
524
					CFileIO Open(sTempDir + "/TLaser.txt");
523
					CFileIO Open(sTempDir + L"/TLaser.txt");
525
					std::vector<Utils::String> *lines = Open.readLines();
524
					std::vector<Utils::WString> lines;
526
					if ( lines )
525
					if(Open.readLines(lines))
527
					{
526
					{
528
						bool first = false;
527
						bool first = false;
529
						for ( int j = 0; j < (int)lines->size(); j++ )
528
						for ( int j = 0; j < (int)lines.size(); j++ )
530
						{
529
						{
531
							Utils::String line(lines->at(j));			
530
							Utils::WString line(lines.at(j));			
532
							if ( line[0] == '/' )
531
							if ( line[0] == '/' )
533
								continue;
532
								continue;
534
							line.removeChar('\r');
533
							line.removeChar('\r');
535
							line = line.removeFirstSpace();
534
							line = line.removeFirstSpace();
536
							line = line.removeEndSpace();
535
							line = line.removeEndSpace();
Line 540... Line 539...
540
							{
539
							{
541
								first = true;
540
								first = true;
542
								continue;
541
								continue;
543
							}
542
							}
544
 
543
 
545
							laserList->PushBack(CyString(line));
544
							laserList->pushBack(line);
546
						}
545
						}
547
					}
546
					}
548
 
547
 
549
					Open.remove();
548
					Open.remove();
550
				}
549
				}
551
 
550
 
552
				if ( p.extractGameFile(L"types/TMissiles.pck", sTempDir + L"/TMissiles.txt", strNode->str.ToString()) )
551
				if ( p.extractGameFile(L"types/TMissiles.pck", sTempDir + L"/TMissiles.txt", (*itr)->str) )
553
				{
552
				{
554
					CFileIO Open(sTempDir + L"/TMissiles.txt");
553
					CFileIO Open(sTempDir + L"/TMissiles.txt");
555
					std::vector<Utils::String> *lines = Open.readLines();
554
					std::vector<Utils::WString> lines;
556
					if ( lines )
555
					if(Open.readLines(lines))
557
					{
556
					{
558
						bool first = false;
557
						bool first = false;
559
						for ( int j = 0; j < (int)lines->size(); j++ )
558
						for ( int j = 0; j < (int)lines.size(); j++ )
560
						{
559
						{
561
							Utils::String line(lines->at(j));			
560
							Utils::WString line(lines.at(j));			
562
							if ( line[0] == '/' )
561
							if ( line[0] == '/' )
563
								continue;
562
								continue;
564
							line.removeChar('\r');
563
							line.removeChar('\r');
565
							line = line.removeFirstSpace();
564
							line = line.removeFirstSpace();
566
							line = line.removeEndSpace();
565
							line = line.removeEndSpace();
Line 570... Line 569...
570
							{
569
							{
571
								first = true;
570
								first = true;
572
								continue;
571
								continue;
573
							}
572
							}
574
 
573
 
575
							missileList->PushBack(CyString(line));
574
							missileList->pushBack(line);
576
						}
575
						}
577
					}
576
					}
578
 
577
 
579
					Open.remove();
578
					Open.remove();
580
				}
579
				}
581
 
580
 
582
				if ( !m_bReadText )
581
				if ( !m_bReadText )
583
					continue;
582
					continue;
584
 
583
 
585
				// load the text file
584
				// load the text file
586
				Utils::String textFormat;
585
				Utils::WString textFormat;
587
				if ( tcText )
586
				if ( tcText )
588
					textFormat = "0001-L044";
587
					textFormat = L"0001-L044";
589
				else
588
				else
590
					textFormat = "440001";
589
					textFormat = L"440001";
591
 
590
 
592
				if ( p.extractGameFile("t/" + textFormat + ".pck", sTempDir + "/" + textFormat + ".xml", strNode->str.ToString()) )
591
				if ( p.extractGameFile(L"t/" + textFormat + L".pck", sTempDir + L"/" + textFormat + L".xml", (*itr)->str) )
593
				{
592
				{
594
					CFileIO Open(sTempDir + textFormat + ".xml");
593
					CFileIO Open(sTempDir + textFormat + L".xml");
595
					if ( Open.startRead() )
594
					if ( Open.startRead() )
596
					{
595
					{
597
						int donePage = (tcText) ? 3 : 2;
596
						int donePage = (tcText) ? 3 : 2;
598
						int inPage = 0;
597
						int inPage = 0;
599
						while ( !Open.atEnd() )
598
						while ( !Open.atEnd() )
600
						{
599
						{
601
							Utils::String line = Open.readEndOfLineStr();
600
							Utils::WString line = Open.readEndOfLine();
602
							if ( line.empty() )
601
							if ( line.empty() )
603
								continue;
602
								continue;
604
							line = line.removeFirstSpace();
603
							line = line.removeFirstSpace();
605
							line = line.remove('\t');
604
							line = line.remove('\t');
606
							if ( !inPage )
605
							if ( !inPage )
607
							{
606
							{
608
								if ( line.left(5).Compare("<page") )
607
								if ( line.left(5).Compare(L"<page") )
609
								{
608
								{
610
									int pos = line.findPos(" id=\"");
609
									int pos = line.findPos(L" id=\"");
611
									if ( pos != -1 )
610
									if ( pos != -1 )
612
									{
611
									{
613
										int endpos = line.findPos("\"", pos + 5);
612
										int endpos = line.findPos(L"\"", pos + 5);
614
										if ( endpos != -1 )
613
										if ( endpos != -1 )
615
										{
614
										{
616
											Utils::String check = line.mid(pos + 6, endpos - pos - 5);
615
											Utils::WString check = line.mid(pos + 6, endpos - pos - 5);
617
											int iPage = check.toInt();
616
											int iPage = check.toInt();
618
											if ( iPage == 17 || iPage == 300017 || iPage == 350017 )
617
											if ( iPage == 17 || iPage == 300017 || iPage == 350017 || iPage == 380017 || iPage == 390017)
619
												inPage = iPage;
618
												inPage = iPage;
620
										}
619
										}
621
									}
620
									}
622
								}
621
								}
623
							}
622
							}
624
							else
623
							else
625
							{
624
							{
626
								if ( line.left(6).Compare("</page") )
625
								if ( line.left(6).Compare(L"</page") )
627
								{
626
								{
628
									inPage = 0;
627
									inPage = 0;
629
									--donePage;
628
									--donePage;
630
 
629
 
631
									if ( donePage <= 0 )
630
									if ( donePage <= 0 )
632
										break;
631
										break;
633
								}
632
								}
634
								else
633
								else
635
								{
634
								{
636
									int pos = line.findPos("t id=\"");
635
									int pos = line.findPos(L"t id=\"");
637
									if ( pos != -1 )
636
									if ( pos != -1 )
638
									{
637
									{
639
										int endpos = line.findPos("\"", pos + 6);
638
										int endpos = line.findPos(L"\"", pos + 6);
640
										if ( endpos != -1 )
639
										if ( endpos != -1 )
641
										{
640
										{
642
											Utils::String check = line.mid(pos + 7, endpos - pos - 6);
641
											Utils::WString check = line.mid(pos + 7, endpos - pos - 6);
643
											
642
											
644
											Utils::String data;
643
											Utils::WString data;
645
											int pos = line.findPos(">", endpos);
644
											int pos = line.findPos(L">", endpos);
646
											if ( pos != -1 )
645
											if ( pos != -1 )
647
											{
646
											{
648
												endpos = line.findPos("</", pos);
647
												endpos = line.findPos(L"</", pos);
649
												if ( endpos != -1 )
648
												if ( endpos != -1 )
650
													data = line.mid(pos + 2, endpos - pos - 1);
649
													data = line.mid(pos + 2, endpos - pos - 1);
651
											}
650
											}
652
											SStringList *str = textList->FindData(check);
651
											Utils::WString find = textList->findData(check);
653
											if ( str )
652
											if (find)
654
												str->str = data;
653
												textList->remove(find);
655
											else
654
											else
656
												textList->PushBack(CyString(data), CyString(check));
655
												textList->pushBack(data, check);
657
										}
656
										}
658
									}
657
									}
659
								}
658
								}
660
							}
659
							}
661
						}
660
						}
Line 674... Line 673...
674
			p.startup(L".", L".", L".");
673
			p.startup(L".", L".", L".");
675
 
674
 
676
			for ( int i = 1; i < p.GetGameExe()->numGames(); i++ )
675
			for ( int i = 1; i < p.GetGameExe()->numGames(); i++ )
677
			{
676
			{
678
				SGameExe *exe = p.GetGameExe()->game(i);
677
				SGameExe *exe = p.GetGameExe()->game(i);
679
				if ( !m_pDirList->FindData(CyString::Number(i)) )
678
				if ( !m_pDirList->containsData(Utils::WString::Number(i)) )
680
				{
679
				{
681
					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 )
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 )
682
					{
681
					{
683
						FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
682
						FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
684
						fbd->Description = "Select the path for " + _US(exe->sName);
683
						fbd->Description = "Select the path for " + _US(exe->sName);
Line 686... Line 685...
686
						{
685
						{
687
							CDirIO Dir(_S(fbd->SelectedPath));
686
							CDirIO Dir(_S(fbd->SelectedPath));
688
							if ( !Dir.exists(exe->sExe) )
687
							if ( !Dir.exists(exe->sExe) )
689
								MessageBox::Show(this, "Unable to find " + _US(exe->sExe) + " in " + fbd->SelectedPath, "Game Directory", MessageBoxButtons::OK, MessageBoxIcon::Warning);
688
								MessageBox::Show(this, "Unable to find " + _US(exe->sExe) + " in " + fbd->SelectedPath, "Game Directory", MessageBoxButtons::OK, MessageBoxIcon::Warning);
690
							else
689
							else
691
								m_pDirList->PushBack(CyStringFromSystemString(fbd->SelectedPath), CyString::Number(i));
690
								m_pDirList->pushBack(_WS(fbd->SelectedPath), Utils::WString::Number(i));
692
						}
691
						}
693
					}
692
					}
694
					else
693
					else
695
						m_pDirList->PushBack("-1", CyString::Number(i));
694
						m_pDirList->pushBack(L"-1", Utils::WString::Number(i));
696
				}
695
				}
697
			}
696
			}
698
 
697
 
699
			if ( !m_pDirList->Empty() )
698
			if ( !m_pDirList->empty() )
700
			{
699
			{
701
				if ( MessageBox::Show(this, "Would you like to load the game data?", "Load Game Data", MessageBoxButtons::YesNo, MessageBoxIcon::Question) == System::Windows::Forms::DialogResult::Yes )
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 )
702
					this->LoadGameData();
701
					this->LoadGameData();
703
			}
702
			}
704
 
703
 
Line 707... Line 706...
707
 
706
 
708
		void CloseDialog()
707
		void CloseDialog()
709
		{
708
		{
710
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
709
			System::String ^mydoc = Environment::GetFolderPath(Environment::SpecialFolder::Personal );
711
			CFileIO Config(_WS(mydoc) + L"/Egosoft/xspconvert.dat");
710
			CFileIO Config(_WS(mydoc) + L"/Egosoft/xspconvert.dat");
712
			std::vector<Utils::String> lines;
711
			std::vector<Utils::WString> lines;
713
			for ( SStringList *str = m_pDirList->;Head(); str; str = str->next )
712
			for(auto itr = m_pDirList->;begin(); itr != m_pDirList->end(); itr++)
714
				lines.push_back("Dir:" + str-&gt;data.ToString() + " " + str->str.ToString());
713
				lines.push_back(L"Dir:" + (*itr)-&gt;data + L" " + (*itr)->str);
715
			if ( m_bReadText )
714
			if ( m_bReadText )
716
				lines.push_back("ReadText");
715
				lines.push_back(L"ReadText");
717
			Config.writeFile(&lines);
716
			Config.writeFile(lines);
718
		}
717
		}
719
 
718
 
720
		void CheckListChanged()
719
		void CheckListChanged()
721
		{
720
		{
722
			if ( m_bDontUpdate )
721
			if ( m_bDontUpdate )
Line 802... Line 801...
802
		void Event_RemoveDirectory(System::Object ^sender, System::EventArgs ^E)
801
		void Event_RemoveDirectory(System::Object ^sender, System::EventArgs ^E)
803
		{
802
		{
804
			System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
803
			System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
805
			if ( item )
804
			if ( item )
806
			{
805
			{
807
				CyString game = CyStringFromSystemString(cli::safe_cast<System::String ^>(item->Tag));
806
				Utils::WString game = _WS(cli::safe_cast<System::String ^>(item->Tag));
808
				game = game.GetToken(" ", 1, 1);
807
				game = game.token(L" ", 1);
809
				if ( m_pDirList->FindData(game) )
808
				Utils::WString find = m_pDirList->findData(game);
-
 
809
				if(find)
810
				{
810
				{
-
 
811
					m_pDirList->remove(find);
811
					m_pDirList->FindData(game)->str = "-1";
812
					m_pDirList->pushBack(L"-1", game);
812
					this->UpdateGames();
813
					this->UpdateGames();
813
				}
814
				}
814
			}
815
			}
815
		}
816
		}
816
 
817
 
817
		void Event_ChangeDirectory(System::Object ^sender, System::EventArgs ^E)
818
		void Event_ChangeDirectory(System::Object ^sender, System::EventArgs ^E)
818
		{
819
		{
819
			System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
820
			System::Windows::Forms::ToolStripMenuItem ^item = cli::safe_cast<System::Windows::Forms::ToolStripMenuItem ^>(sender);
820
			if ( item )
821
			if ( item )
821
			{
822
			{
822
				Utils::String tag = _S(cli::safe_cast<System::String ^>(item->Tag));
823
				Utils::WString tag = _S(cli::safe_cast<System::String ^>(item->Tag));
823
				Utils::String game = tag.token(" ", 1);
824
				Utils::WString game = tag.token(L" ", 1);
824
				if ( m_pDirList->FindData(game) )
825
				if ( m_pDirList->containsData(game) )
825
				{
826
				{
826
					FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
827
					FolderBrowserDialog ^fbd = gcnew FolderBrowserDialog;
827
					fbd->Description = "Select the path for " + _US(tag.tokens(" ", 2));
828
					fbd->Description = "Select the path for " + _US(tag.tokens(L" ", 2));
828
					if ( fbd->ShowDialog() == System::Windows::Forms::DialogResult::OK )
829
					if ( fbd->ShowDialog() == System::Windows::Forms::DialogResult::OK )
829
					{
830
					{
-
 
831
						Utils::WString data = m_pDirList->findData(game);
-
 
832
						m_pDirList->remove(data);
830
						m_pDirList->FindData(game)->str = _S(fbd->SelectedPath);
833
						m_pDirList->pushBack(_WS(fbd->SelectedPath), game);
831
						this->UpdateGames();
834
						this->UpdateGames();
832
					}					
835
					}					
833
				}
836
				}
834
			}
837
			}
835
		}
838
		}