Subversion Repositories spk

Rev

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

Rev 211 Rev 212
Line 1441... Line 1441...
1441
		}
1441
		}
1442
	}
1442
	}
1443
 
1443
 
1444
	return data;
1444
	return data;
1445
}
1445
}
-
 
1446
 
-
 
1447
bool CXspFile::ReadAnimations(const Utils::WStringList& lIn, Utils::WStringList& lOut, int startRecord)
-
 
1448
{
-
 
1449
	Utils::WString lastComment;
-
 
1450
	Utils::WString addEntry;
-
 
1451
	int remaining = 0;
-
 
1452
	Utils::WString lastType;
-
 
1453
	int newEntries = 0;
-
 
1454
	int entries = -1;
-
 
1455
	for (auto itr = lIn.begin(); itr != lIn.end(); itr++)
-
 
1456
	{
-
 
1457
		Utils::WString line = (*itr)->str;
-
 
1458
		line.removeChar('\r');
-
 
1459
		line.removeChar(9);
-
 
1460
		if (line.empty() || line[0] == '/')
-
 
1461
			continue;
-
 
1462
		if (entries == -1)
-
 
1463
		{
-
 
1464
			entries = line.token(L";", 1);
-
 
1465
			newEntries = entries - startRecord;
-
 
1466
		}
-
 
1467
		else
-
 
1468
		{
-
 
1469
			// remove comments, endspaces and last ;
-
 
1470
			Utils::WString sStriped = line;
-
 
1471
			if (sStriped.isin("//"))
-
 
1472
			{
-
 
1473
				if (entries <= newEntries)
-
 
1474
					lastComment = L"//" + sStriped.tokens(L"//", 2);
-
 
1475
				sStriped = sStriped.token(L"//", 1);
-
 
1476
			}
-
 
1477
			sStriped.removeEndSpace();
-
 
1478
			if (sStriped.right(1) == L";")
-
 
1479
				sStriped.truncate(-1);
-
 
1480
 
-
 
1481
			Utils::WString sRemainingLeft;
-
 
1482
			if (remaining > 0)
-
 
1483
				sRemainingLeft = sStriped;
-
 
1484
			else
-
 
1485
			{
-
 
1486
				// each line should be a new entry, with some exceptions
-
 
1487
				// potection for new lines
-
 
1488
				lastType = sStriped.token(L";", 1);
-
 
1489
 
-
 
1490
				switch (CXspFile::GetAnimationType(lastType.toString()))
-
 
1491
				{
-
 
1492
				case TAT_SINGLE:
-
 
1493
					remaining = (long)sStriped.token(L";", 5) + 1;
-
 
1494
					sRemainingLeft = sStriped.tokens(L";", 6);
-
 
1495
					if (entries <= newEntries)
-
 
1496
						addEntry = sStriped.tokens(L";", 1, 5) + L";";
-
 
1497
					break;
-
 
1498
				case TAT_3:
-
 
1499
					remaining = (long)sStriped.token(L";", 5) + 1;
-
 
1500
					sRemainingLeft = sStriped.tokens(L";", 6);
-
 
1501
					if (entries <= newEntries)
-
 
1502
						addEntry = sStriped.tokens(L";", 1, 5) + L";";
-
 
1503
					break;
-
 
1504
 
-
 
1505
				default:
-
 
1506
					remaining = 0;
-
 
1507
					if (entries <= newEntries)
-
 
1508
						addEntry = sStriped;
-
 
1509
 
-
 
1510
				}
-
 
1511
			}
-
 
1512
 
-
 
1513
			if (!sRemainingLeft.empty())
-
 
1514
			{
-
 
1515
				int tatType = CXspFile::GetAnimationType(lastType.toString());
-
 
1516
				if (tatType == TAT_SINGLE)
-
 
1517
				{
-
 
1518
					if (sRemainingLeft.contains(L";"))
-
 
1519
						remaining -= sRemainingLeft.countToken(L";");
-
 
1520
					else if (!sRemainingLeft.empty())
-
 
1521
						--remaining;
-
 
1522
 
-
 
1523
					if (entries <= newEntries)
-
 
1524
						addEntry += sRemainingLeft + L";";
-
 
1525
				}
-
 
1526
				else if (tatType == TAT_3)
-
 
1527
				{
-
 
1528
					// last entry
-
 
1529
					if (remaining == 1)
-
 
1530
						--remaining;
-
 
1531
					else if (sRemainingLeft.contains(L";"))
-
 
1532
					{
-
 
1533
						if (!sRemainingLeft.contains(L"TATF_COORDS"))
-
 
1534
						{
-
 
1535
							int amt = sRemainingLeft.countToken(L";") / 3;
-
 
1536
							remaining -= amt;
-
 
1537
							if (remaining == 1 && (sRemainingLeft.countToken(L";") - (amt * 3)) == 1)
-
 
1538
								--remaining;
-
 
1539
						}
-
 
1540
						else
-
 
1541
						{
-
 
1542
							int iRem = sRemainingLeft.countToken(L";");
-
 
1543
							int iPos = 1;
-
 
1544
							while (iPos < iRem)
-
 
1545
							{
-
 
1546
								Utils::WString first = sRemainingLeft.token(L";", iPos);
-
 
1547
								if (first.contains(L"TATF_COORDS"))
-
 
1548
									iPos += 5;
-
 
1549
								else
-
 
1550
									iPos += 3;
-
 
1551
								--remaining;
-
 
1552
							}
-
 
1553
 
-
 
1554
							if (remaining == 1 && iPos == iRem)
-
 
1555
								--remaining;
-
 
1556
						}
-
 
1557
					}
-
 
1558
 
-
 
1559
					if (entries <= newEntries)
-
 
1560
						addEntry += sRemainingLeft + L";";
-
 
1561
				}
-
 
1562
			}
-
 
1563
 
-
 
1564
			if (remaining <= 0)
-
 
1565
			{
-
 
1566
				if (entries <= newEntries && !addEntry.empty())
-
 
1567
				{
-
 
1568
					if (addEntry[(int)addEntry.length() - 1] != ';')
-
 
1569
						addEntry += L";";
-
 
1570
					lOut.pushBack(addEntry + lastComment);
-
 
1571
				}
-
 
1572
				--entries;
-
 
1573
			}
-
 
1574
		}
-
 
1575
	}
-
 
1576
 
-
 
1577
	return !lOut.empty();
-
 
1578
}
-
 
1579
 
1446
 
1580
 
1447
bool CXspFile::ReadAnimations(const Utils::CStringList &lIn, Utils::CStringList &lOut, int startRecord)
1581
bool CXspFile::ReadAnimations(const Utils::CStringList &lIn, Utils::CStringList &lOut, int startRecord)
1448
{
1582
{
1449
	Utils::String lastComment;
1583
	Utils::String lastComment;
1450
	Utils::String addEntry;
1584
	Utils::String addEntry;