Subversion Repositories spk

Rev

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

Rev 14 Rev 17
Line 5387... Line 5387...
5387
			CLEANSPLIT(empStr, empEntries);
5387
			CLEANSPLIT(empStr, empEntries);
5388
		}
5388
		}
5389
	}
5389
	}
5390
}
5390
}
5391
 
5391
 
-
 
5392
CyString parseXmlText(const CyString &str)
-
 
5393
{
-
 
5394
	CyString newStr(str);
-
 
5395
	CyStringList changes;
-
 
5396
 
-
 
5397
	// find all XML commands, &<command>;
-
 
5398
	std::string sStr = str.ToString();
-
 
5399
	std::string::size_type pos = sStr.find_first_of("&", 0);
-
 
5400
	while ( pos != std::string::npos ) {
-
 
5401
		// find the next space and next ;.  If ; comes first, assume its acommand
-
 
5402
		std::string::size_type spacePos = sStr.find_first_of(" ", pos);
-
 
5403
		std::string::size_type colonPos = sStr.find_first_of(";", pos);
-
 
5404
		if ( colonPos != std::string::npos && colonPos < spacePos ) {
-
 
5405
			// replace with <::command::> so they the & doesn't get replaced
-
 
5406
			std::string repStr = sStr.substr(pos, (colonPos + 1) - pos);
-
 
5407
			std::string repWithStr = "<::" + sStr.substr(pos + 1, colonPos - pos - 1) + "::>";
-
 
5408
			newStr.FindReplace(repStr, repWithStr);
-
 
5409
			changes.PushBack(repStr, repWithStr);
-
 
5410
		}
-
 
5411
 
-
 
5412
		// find the next command
-
 
5413
		pos = sStr.find_first_of("&", pos + 1);
-
 
5414
	}
-
 
5415
 
-
 
5416
	// replace the & now
-
 
5417
	newStr = newStr.FindReplace("&", "&amp;");
-
 
5418
 
-
 
5419
	// restore the commands
-
 
5420
	for ( SStringList *strNode = changes.Head(); strNode; strNode = strNode->next ) {
-
 
5421
		newStr.FindReplace(strNode->data, strNode->str);
-
 
5422
	}
-
 
5423
 
-
 
5424
	return newStr;
-
 
5425
}
-
 
5426
 
5392
CyString CPackages::ConvertTextString(CyString text)
5427
CyString CPackages::ConvertTextString(CyString text)
5393
{
5428
{
-
 
5429
	//process any &
-
 
5430
	text = parseXmlText(text);
-
 
5431
 
-
 
5432
	// change special cases
5394
	text = text.FindReplace("(", "\\(");
5433
	text = text.FindReplace("(", "\\(");
5395
	text = text.FindReplace(")", "\\)");
5434
	text = text.FindReplace(")", "\\)");
5396
	text = text.FindReplace("[", "{");
5435
	text = text.FindReplace("[", "{");
5397
	text = text.FindReplace("]", "}");
5436
	text = text.FindReplace("]", "}");
5398
	text = text.FindReplace(">", "&gt;");
5437
	text = text.FindReplace(">", "&gt;");
5399
	text = text.FindReplace("<", "&lt;");
5438
	text = text.FindReplace("<", "&lt;");
5400
	text = text.FindReplace("&", "&amp;");
-
 
5401
	return text;
5439
	return text;
5402
}
5440
}
5403
 
5441
 
5404
void CPackages::CreatePluginManagerText()
5442
void CPackages::CreatePluginManagerText()
5405
{
5443
{
Line 5557... Line 5595...
5557
		writeData.push_back(CyString("		<t id=\"5\">") + CyString::Number(start) + "</t>");
5595
		writeData.push_back(CyString("		<t id=\"5\">") + CyString::Number(start) + "</t>");
5558
		for ( CListNode<SGameWare> *node = lWares.Front(); node; node = node->next() )
5596
		for ( CListNode<SGameWare> *node = lWares.Front(); node; node = node->next() )
5559
		{
5597
		{
5560
			SGameWare *w = node->Data();
5598
			SGameWare *w = node->Data();
5561
			if ( w->pWare && w->iType == WARETYPE_ADDED )
5599
			if ( w->pWare && w->iType == WARETYPE_ADDED )
5562
				writeData.push_back(CyString("		<t id=\"") + (long)start + "\">" + w->sWareName + "</t>");
5600
				writeData.push_back(CyString("		<t id=\"") + (long)start + "\">" + this->ConvertTextString(w->sWareName) + "</t>");
5563
			else
5601
			else
5564
				writeData.push_back(CyString("		<t id=\"") + (long)start + "\">-1</t>");
5602
				writeData.push_back(CyString("		<t id=\"") + (long)start + "\">-1</t>");
5565
			writeData.push_back(CyString("		<t id=\"") + (long)(start + 1) + "\">" + CyString((char)w->cType) + "</t>");
5603
			writeData.push_back(CyString("		<t id=\"") + (long)(start + 1) + "\">" + CyString((char)w->cType) + "</t>");
5566
			writeData.push_back(CyString("		<t id=\"") + (long)(start + 2) + "\">" + (long)w->iPos + "</t>");
5604
			writeData.push_back(CyString("		<t id=\"") + (long)(start + 2) + "\">" + (long)w->iPos + "</t>");
5567
			start += 10;
5605
			start += 10;
Line 5622... Line 5660...
5622
 
5660
 
5623
			// find the correct text for the language
5661
			// find the correct text for the language
5624
			CyString name = CSpkFile::GetWareText(w->pWare, m_iLanguage);
5662
			CyString name = CSpkFile::GetWareText(w->pWare, m_iLanguage);
5625
			CyString desc = CSpkFile::GetWareDesc(w->pWare, m_iLanguage);
5663
			CyString desc = CSpkFile::GetWareDesc(w->pWare, m_iLanguage);
5626
			if ( !name.Empty() )
5664
			if ( !name.Empty() )
5627
				writeData.push_back(CyString("		<t id=\"") + (long)(w->iText + 3) + "\">" + name + "</t>");
5665
				writeData.push_back(CyString("		<t id=\"") + (long)(w->iText + 3) + "\">" + this->ConvertTextString(name) + "</t>");
5628
			if ( !desc.Empty() )
5666
			if ( !desc.Empty() )
5629
				writeData.push_back(CyString("		<t id=\"") + (long)(w->iText + 4) + "\">" + desc + "</t>");
5667
				writeData.push_back(CyString("		<t id=\"") + (long)(w->iText + 4) + "\">" + this->ConvertTextString(desc) + "</t>");
5630
		}
5668
		}
5631
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
5669
		for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
5632
		{
5670
		{
5633
			SGameShip *s = node->Data();
5671
			SGameShip *s = node->Data();
5634
			if ( !s->pPackage || s->iType != WARETYPE_ADDED )
5672
			if ( !s->pPackage || s->iType != WARETYPE_ADDED )
Line 5637... Line 5675...
5637
				continue;
5675
				continue;
5638
 
5676
 
5639
			CyString name = s->pPackage->GetTextName(m_iLanguage);
5677
			CyString name = s->pPackage->GetTextName(m_iLanguage);
5640
			CyString desc = s->pPackage->GetTextDescription(m_iLanguage);
5678
			CyString desc = s->pPackage->GetTextDescription(m_iLanguage);
5641
			if ( !name.Empty() )
5679
			if ( !name.Empty() )
5642
				writeData.push_back(CyString("		<t id=\"") + (long)s->iText + "\">" + name + "</t>");
5680
				writeData.push_back(CyString("		<t id=\"") + (long)s->iText + "\">" + this->ConvertTextString(name) + "</t>");
5643
			if ( !desc.Empty() )
5681
			if ( !desc.Empty() )
5644
				writeData.push_back(CyString("		<t id=\"") + (long)(s->iText + 1) + "\">" + desc + "</t>");
5682
				writeData.push_back(CyString("		<t id=\"") + (long)(s->iText + 1) + "\">" + this->ConvertTextString(desc) + "</t>");
5645
		}
5683
		}
5646
		writeData.push_back(CyString("  </page>"));
5684
		writeData.push_back(CyString("  </page>"));
5647
	}
5685
	}
5648
	writeData.push_back(CyString("</language>"));
5686
	writeData.push_back(CyString("</language>"));
5649
	textFile.WriteFileUTF(&writeData);
5687
	textFile.WriteFileUTF(&writeData);
Line 8395... Line 8433...
8395
				if ( fileName.Compare("pluginmanager.txt") )
8433
				if ( fileName.Compare("pluginmanager.txt") )
8396
					this->ReadArchiveData(File.GetFullFilename(), archive);
8434
					this->ReadArchiveData(File.GetFullFilename(), archive);
8397
				else
8435
				else
8398
				{
8436
				{
8399
					CyString extradir;
8437
					CyString extradir;
8400
					int type = SPK::GetAutomaticFiletype(fileName, &extradir);
8438
					int type = SPK::GetAutomaticFiletype(fileName, &extradir, true);
8401
 
-
 
-
 
8439
					// check for special file types
8402
					C_File *f = NULL;
8440
					C_File *f = NULL;
-
 
8441
 
-
 
8442
					if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
-
 
8443
						f = archive->AddFile(CFileIO(fileName).GetFilename(), CFileIO(fileName).GetDir(), FILETYPE_SCRIPT);
-
 
8444
						if ( f ) {
-
 
8445
							f->ReadFromFile(File.GetFullFilename());
-
 
8446
						}
-
 
8447
						type = FILETYPE_UNINSTALL;
-
 
8448
					}
-
 
8449
 
8403
					if ( type == -1 )
8450
					if ( type == -1 )
8404
						f = archive->AddFile(CFileIO(fileName).GetFilename(), CFileIO(fileName).GetDir(), FILETYPE_EXTRA);
8451
						f = archive->AddFile(CFileIO(fileName).GetFilename(), CFileIO(fileName).GetDir(), FILETYPE_EXTRA);
8405
					else
8452
					else
8406
						f = archive->AddFile(CFileIO(fileName).GetFilename(), extradir, type);
8453
						f = archive->AddFile(CFileIO(fileName).GetFilename(), extradir, type);
8407
					f->ReadFromFile(File.GetFullFilename());
8454
					f->ReadFromFile(File.GetFullFilename());
Line 8474... Line 8521...
8474
				delete[] iBuf;
8521
				delete[] iBuf;
8475
			}
8522
			}
8476
			else
8523
			else
8477
			{
8524
			{
8478
				CyString extradir;
8525
				CyString extradir;
8479
				int type = SPK::GetAutomaticFiletype(Name, &extradir);
8526
				int type = SPK::GetAutomaticFiletype(Name, &extradir, true);
8480
 
8527
 
8481
				C_File *f = NULL;
8528
				C_File *f = NULL;
-
 
8529
 
-
 
8530
				// check for special file types
-
 
8531
				if ( type == FILETYPE_SCRIPT_UNINSTALL ) {
-
 
8532
					f = archive->AddFile(CFileIO(Name).GetFilename(), CFileIO(Name).GetDir(), FILETYPE_SCRIPT);
-
 
8533
					if ( f ) {
-
 
8534
						f->SetData((const unsigned char *)iBuf, ze.unc_size);
-
 
8535
					}
-
 
8536
					type = FILETYPE_UNINSTALL;
-
 
8537
				}
-
 
8538
 
8482
				if ( type == -1 )
8539
				if ( type == -1 )
8483
					f = archive->AddFile(CFileIO(Name).GetFilename(), CFileIO(Name).GetDir(), FILETYPE_EXTRA);
8540
					f = archive->AddFile(CFileIO(Name).GetFilename(), CFileIO(Name).GetDir(), FILETYPE_EXTRA);
8484
				else
8541
				else
8485
					f = archive->AddFile(CFileIO(Name).GetFilename(), extradir, type);
8542
					f = archive->AddFile(CFileIO(Name).GetFilename(), extradir, type);
8486
 
8543