2012-03-20 01:57:42 +01:00
|
|
|
#include "lc_global.h"
|
2011-09-07 23:06:51 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "group.h"
|
2012-03-21 02:54:03 +01:00
|
|
|
#include "lc_file.h"
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-25 03:45:19 +02:00
|
|
|
lcGroup::lcGroup()
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
2017-04-14 02:26:40 +02:00
|
|
|
mGroup = nullptr;
|
2011-09-07 23:06:51 +02:00
|
|
|
}
|
|
|
|
|
2014-05-25 03:45:19 +02:00
|
|
|
lcGroup::~lcGroup()
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-25 20:23:09 +02:00
|
|
|
void lcGroup::FileLoad(lcFile* File)
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
2014-05-25 20:23:09 +02:00
|
|
|
lcint32 GroupIndex;
|
2015-10-21 17:03:45 +02:00
|
|
|
char Name[LC_MAX_GROUP_NAME + 1];
|
2014-05-25 20:23:09 +02:00
|
|
|
|
2014-06-18 03:14:45 +02:00
|
|
|
File->ReadU8();
|
2015-10-21 17:03:45 +02:00
|
|
|
File->ReadBuffer(Name, sizeof(Name));
|
|
|
|
mName = QString::fromUtf8(Name);
|
2014-05-25 20:23:09 +02:00
|
|
|
File->ReadVector3();
|
|
|
|
File->ReadS32(&GroupIndex, 1);
|
2016-02-19 18:53:54 +01:00
|
|
|
mGroup = (lcGroup*)(quintptr)GroupIndex;
|
2011-09-07 23:06:51 +02:00
|
|
|
}
|
|
|
|
|
2014-12-16 00:55:17 +01:00
|
|
|
void lcGroup::CreateName(const lcArray<lcGroup*>& Groups)
|
|
|
|
{
|
2015-10-21 17:03:45 +02:00
|
|
|
if (!mName.isEmpty())
|
2014-12-16 00:55:17 +01:00
|
|
|
{
|
|
|
|
bool Found = false;
|
|
|
|
for (int GroupIdx = 0; GroupIdx < Groups.GetSize(); GroupIdx++)
|
|
|
|
{
|
2015-10-21 17:03:45 +02:00
|
|
|
if (Groups[GroupIdx]->mName == mName)
|
2014-12-16 00:55:17 +01:00
|
|
|
{
|
|
|
|
Found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Found)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-21 17:03:45 +02:00
|
|
|
int Max = 0;
|
|
|
|
QString Prefix = QApplication::tr("Group #");
|
|
|
|
int Length = Prefix.length();
|
2014-12-16 00:55:17 +01:00
|
|
|
|
|
|
|
for (int GroupIdx = 0; GroupIdx < Groups.GetSize(); GroupIdx++)
|
2015-10-21 17:03:45 +02:00
|
|
|
{
|
|
|
|
const QString& Name = Groups[GroupIdx]->mName;
|
|
|
|
|
|
|
|
if (Name.startsWith(Prefix))
|
|
|
|
{
|
|
|
|
bool Ok = false;
|
2017-04-21 03:56:35 +02:00
|
|
|
int GroupNumber = Name.mid(Length).toInt(&Ok);
|
2015-10-21 17:03:45 +02:00
|
|
|
if (Ok && GroupNumber > Max)
|
|
|
|
Max = GroupNumber;
|
|
|
|
}
|
|
|
|
}
|
2014-12-16 00:55:17 +01:00
|
|
|
|
2015-10-21 17:03:45 +02:00
|
|
|
mName = Prefix + QString::number(Max + 1);
|
2014-12-16 00:55:17 +01:00
|
|
|
}
|