Don't uppercase part names when saving.

This commit is contained in:
Leonardo Zide 2017-07-27 09:21:55 -07:00
parent 506c5ef67a
commit 82528a2c7a
11 changed files with 171 additions and 178 deletions

View file

@ -111,9 +111,25 @@ void lcPiecesLibrary::RemovePiece(PieceInfo* Info)
void lcPiecesLibrary::RenamePiece(PieceInfo* Info, const char* NewName)
{
mPieces.erase(Info->m_strName);
strcpy(Info->m_strName, NewName);
mPieces[Info->m_strName] = Info;
for (auto PieceIt = mPieces.begin(); PieceIt != mPieces.end(); PieceIt++)
{
if (PieceIt->second == Info)
{
mPieces.erase(PieceIt);
break;
}
}
strncpy(Info->mFileName, NewName, sizeof(Info->mFileName));
Info->mFileName[sizeof(Info->mFileName) - 1] = 0;
strncpy(Info->m_strDescription, NewName, sizeof(Info->m_strDescription));
Info->m_strDescription[sizeof(Info->m_strDescription) - 1] = 0;
char PieceName[LC_PIECE_NAME_LEN];
strcpy(PieceName, Info->mFileName);
strupr(PieceName);
mPieces[PieceName] = Info;
}
PieceInfo* lcPiecesLibrary::FindPiece(const char* PieceName, Project* CurrentProject, bool CreatePlaceholder, bool SearchProjectFolder)
@ -127,7 +143,25 @@ PieceInfo* lcPiecesLibrary::FindPiece(const char* PieceName, Project* CurrentPro
ProjectPath = QFileInfo(FileName).absolutePath();
}
const auto PieceIt = mPieces.find(PieceName);
char CleanName[LC_PIECE_NAME_LEN];
const char* Src = PieceName;
char* Dst = CleanName;
while (*Src && Dst - CleanName != sizeof(CleanName))
{
if (*Src == '\\')
*Dst = '/';
else if (*Src >= 'a' && *Src <= 'z')
*Dst = *Src + 'A' - 'a';
else
*Dst = *Src;
Src++;
Dst++;
}
*Dst = 0;
const auto PieceIt = mPieces.find(CleanName);
if (PieceIt != mPieces.end())
{
@ -149,8 +183,8 @@ PieceInfo* lcPiecesLibrary::FindPiece(const char* PieceName, Project* CurrentPro
{
PieceInfo* Info = new PieceInfo();
Info->SetProject(NewProject, PieceName);
mPieces[Info->m_strName] = Info;
Info->CreateProject(NewProject, PieceName);
mPieces[CleanName] = Info;
return Info;
}
@ -164,7 +198,7 @@ PieceInfo* lcPiecesLibrary::FindPiece(const char* PieceName, Project* CurrentPro
PieceInfo* Info = new PieceInfo();
Info->CreatePlaceholder(PieceName);
mPieces[Info->m_strName] = Info;
mPieces[CleanName] = Info;
return Info;
}
@ -301,6 +335,7 @@ bool lcPiecesLibrary::OpenArchive(lcFile* File, const QString& FileName, lcZipFi
if (Dst - Name <= 4)
continue;
*Dst = 0;
Dst -= 4;
if (memcmp(Dst, ".DAT", 4))
{
@ -316,7 +351,6 @@ bool lcPiecesLibrary::OpenArchive(lcFile* File, const QString& FileName, lcZipFi
continue;
}
*Dst = 0;
if (ZipFileType == LC_ZIPFILE_OFFICIAL)
{
@ -338,10 +372,10 @@ bool lcPiecesLibrary::OpenArchive(lcFile* File, const QString& FileName, lcZipFi
{
Info = new PieceInfo();
strncpy(Info->m_strName, Name, sizeof(Info->m_strName));
Info->m_strName[sizeof(Info->m_strName) - 1] = 0;
strncpy(Info->mFileName, FileInfo.file_name + (Name - NameBuffer), sizeof(Info->mFileName));
Info->mFileName[sizeof(Info->mFileName) - 1] = 0;
mPieces[Info->m_strName] = Info;
mPieces[Name] = Info;
}
Info->SetZipFile(ZipFileType, FileIdx);
@ -351,7 +385,7 @@ bool lcPiecesLibrary::OpenArchive(lcFile* File, const QString& FileName, lcZipFi
lcLibraryPrimitive* Primitive = FindPrimitive(Name);
if (!Primitive)
mPrimitives[Name] = new lcLibraryPrimitive(Name, ZipFileType, FileIdx, false, true);
mPrimitives[Name] = new lcLibraryPrimitive(FileInfo.file_name + (Name - NameBuffer), ZipFileType, FileIdx, false, true);
else
Primitive->SetZipFile(ZipFileType, FileIdx);
}
@ -363,7 +397,7 @@ bool lcPiecesLibrary::OpenArchive(lcFile* File, const QString& FileName, lcZipFi
lcLibraryPrimitive* Primitive = FindPrimitive(Name);
if (!Primitive)
mPrimitives[Name] = new lcLibraryPrimitive(Name, ZipFileType, FileIdx, (memcmp(Name, "STU", 3) == 0), false);
mPrimitives[Name] = new lcLibraryPrimitive(FileInfo.file_name + (Name - NameBuffer), ZipFileType, FileIdx, (memcmp(Name, "STU", 3) == 0), false);
else
Primitive->SetZipFile(ZipFileType, FileIdx);
}
@ -442,6 +476,9 @@ bool lcPiecesLibrary::OpenDirectory(const QDir& LibraryDir)
while (PartsList.ReadLine(Line, sizeof(Line)))
{
char OriginalLine[1024];
strcpy(OriginalLine, Line);
char* Chr = Line;
char* Ext = nullptr;
@ -461,7 +498,12 @@ bool lcPiecesLibrary::OpenDirectory(const QDir& LibraryDir)
}
if (Ext && !strcmp(Ext, ".DAT"))
{
*Ext = 0;
OriginalLine[Ext - Line + 4] = 0;
}
else
continue;
while (*Chr && isspace(*Chr))
Chr++;
@ -484,13 +526,13 @@ bool lcPiecesLibrary::OpenDirectory(const QDir& LibraryDir)
PieceInfo* Info = new PieceInfo();
strncpy(Info->m_strName, Line, sizeof(Info->m_strName));
Info->m_strName[sizeof(Info->m_strName) - 1] = 0;
strncpy(Info->mFileName, OriginalLine, sizeof(Info->mFileName));
Info->mFileName[sizeof(Info->mFileName) - 1] = 0;
strncpy(Info->m_strDescription, Description, sizeof(Info->m_strDescription));
Info->m_strDescription[sizeof(Info->m_strDescription) - 1] = 0;
mPieces[Info->m_strName] = Info;
mPieces[Line] = Info;
}
}
@ -529,7 +571,6 @@ bool lcPiecesLibrary::OpenDirectory(const QDir& LibraryDir)
Dst -= 4;
if (memcmp(Dst, ".DAT", 4))
continue;
*Dst = 0;
if (mHasUnofficial && mPieces.find(Name) != mPieces.end())
continue;
@ -562,10 +603,10 @@ bool lcPiecesLibrary::OpenDirectory(const QDir& LibraryDir)
break;
}
strncpy(Info->m_strName, Name, sizeof(Info->m_strName));
Info->m_strName[sizeof(Info->m_strName) - 1] = 0;
strncpy(Info->mFileName, FileString, sizeof(Info->mFileName));
Info->mFileName[sizeof(Info->mFileName) - 1] = 0;
mPieces[Info->m_strName] = Info;
mPieces[Name] = Info;
}
}
}
@ -613,7 +654,6 @@ bool lcPiecesLibrary::OpenDirectory(const QDir& LibraryDir)
Dst -= 4;
if (memcmp(Dst, ".DAT", 4))
continue;
*Dst = 0;
if (mHasUnofficial && IsPrimitive(Name))
continue;
@ -622,7 +662,7 @@ bool lcPiecesLibrary::OpenDirectory(const QDir& LibraryDir)
mHasUnofficial = true;
bool SubFile = SubFileDirectories[DirectoryIdx];
mPrimitives[Name] = new lcLibraryPrimitive(Name, LC_NUM_ZIPFILES, 0, !SubFile && (memcmp(Name, "STU", 3) == 0), SubFile);
mPrimitives[Name] = new lcLibraryPrimitive((strchr(PrimitiveDirectories[DirectoryIdx], '/') + 1) + FileString, LC_NUM_ZIPFILES, 0, !SubFile && (memcmp(Name, "STU", 3) == 0), SubFile);
}
}
}
@ -878,7 +918,7 @@ bool lcPiecesLibrary::SaveCacheIndex(const QString& FileName)
bool lcPiecesLibrary::LoadCachePiece(PieceInfo* Info)
{
QString FileName = QFileInfo(QDir(mCachePath), QString::fromLatin1(Info->m_strName)).absoluteFilePath();
QString FileName = QFileInfo(QDir(mCachePath), QString::fromLatin1(Info->mFileName)).absoluteFilePath();
lcMemFile MeshData;
if (!ReadCacheFile(FileName, MeshData))
@ -914,7 +954,7 @@ bool lcPiecesLibrary::SaveCachePiece(PieceInfo* Info)
if (!Info->GetMesh()->FileSave(MeshData))
return false;
QString FileName = QFileInfo(QDir(mCachePath), QString::fromLatin1(Info->m_strName)).absoluteFilePath();
QString FileName = QFileInfo(QDir(mCachePath), QString::fromLatin1(Info->mFileName)).absoluteFilePath();
return WriteCacheFile(FileName, MeshData);
}
@ -1078,16 +1118,12 @@ bool lcPiecesLibrary::LoadPieceData(PieceInfo* Info)
}
else
{
char Name[LC_PIECE_NAME_LEN];
strcpy(Name, Info->m_strName);
strlwr(Name);
char FileName[LC_MAXPATH];
lcDiskFile PieceFile;
if (mHasUnofficial)
{
sprintf(FileName, "unofficial/parts/%s.dat", Name);
sprintf(FileName, "unofficial/parts/%s", Info->mFileName);
PieceFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
if (PieceFile.Open(QIODevice::ReadOnly))
Loaded = ReadMeshData(PieceFile, lcMatrix44Identity(), 16, false, TextureStack, MeshData, LC_MESHDATA_SHARED, true, nullptr, false);
@ -1095,7 +1131,7 @@ bool lcPiecesLibrary::LoadPieceData(PieceInfo* Info)
if (!Loaded)
{
sprintf(FileName, "parts/%s.dat", Name);
sprintf(FileName, "parts/%s", Info->mFileName);
PieceFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
if (PieceFile.Open(QIODevice::ReadOnly))
Loaded = ReadMeshData(PieceFile, lcMatrix44Identity(), 16, false, TextureStack, MeshData, LC_MESHDATA_SHARED, true, nullptr, false);
@ -1820,13 +1856,6 @@ bool lcPiecesLibrary::ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransf
*Ch = '/';
}
if (Ch - FileName > 4)
{
Ch -= 4;
if (!memcmp(Ch, ".DAT", 4))
*Ch = 0;
}
lcLibraryPrimitive* Primitive = FindPrimitive(FileName);
lcMatrix44 IncludeTransform(lcVector4(fm[3], fm[6], fm[9], 0.0f), lcVector4(fm[4], fm[7], fm[10], 0.0f), lcVector4(fm[5], fm[8], fm[11], 0.0f), lcVector4(fm[0], fm[1], fm[2], 1.0f));
IncludeTransform = lcMul(IncludeTransform, CurrentTransform);
@ -1905,23 +1934,19 @@ bool lcPiecesLibrary::ReadMeshData(lcFile& File, const lcMatrix44& CurrentTransf
}
else
{
char Name[LC_PIECE_NAME_LEN];
strcpy(Name, Info->m_strName);
strlwr(Name);
lcDiskFile IncludeFile;
bool Found = false;
if (mHasUnofficial)
{
sprintf(FileName, "unofficial/parts/%s.dat", Name);
sprintf(FileName, "unofficial/parts/%s", Info->mFileName);
IncludeFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
Found = IncludeFile.Open(QIODevice::ReadOnly);
}
if (!Found)
{
sprintf(FileName, "parts/%s.dat", Name);
sprintf(FileName, "parts/%s", Info->mFileName);
IncludeFile.SetFileName(mLibraryDir.absoluteFilePath(QLatin1String(FileName)));
Found = IncludeFile.Open(QIODevice::ReadOnly);
}
@ -2744,8 +2769,9 @@ void lcPiecesLibrary::GetCategoryEntries(const char* CategoryKeywords, bool Grou
// Find the parent of this patterned piece.
char ParentName[LC_PIECE_NAME_LEN];
strcpy(ParentName, Info->m_strName);
strcpy(ParentName, Info->mFileName);
*strchr(ParentName, 'P') = '\0';
strcat(ParentName, ".dat");
Parent = FindPiece(ParentName, nullptr, false, false);
@ -2782,34 +2808,33 @@ void lcPiecesLibrary::GetCategoryEntries(const char* CategoryKeywords, bool Grou
void lcPiecesLibrary::GetPatternedPieces(PieceInfo* Parent, lcArray<PieceInfo*>& Pieces) const
{
char Name[LC_PIECE_NAME_LEN];
strcpy(Name, Parent->m_strName);
strcpy(Name, Parent->mFileName);
char* Ext = strchr(Name, '.');
if (Ext)
*Ext = 0;
strcat(Name, "P");
strupr(Name);
Pieces.RemoveAll();
for (const auto PieceIt : mPieces)
{
PieceInfo* Info = PieceIt.second;
if (strncmp(Name, Info->m_strName, strlen(Name)) == 0)
Pieces.Add(Info);
}
if (strncmp(Name, PieceIt.first.c_str(), strlen(Name)) == 0)
Pieces.Add(PieceIt.second);
// Sometimes pieces with A and B versions don't follow the same convention (for example, 3040Pxx instead of 3040BPxx).
if (Pieces.GetSize() == 0)
{
strcpy(Name, Parent->m_strName);
strcpy(Name, Parent->mFileName);
Ext = strchr(Name, '.');
if (Ext)
*Ext = 0;
size_t Len = strlen(Name);
if (Name[Len-1] < '0' || Name[Len-1] > '9')
Name[Len-1] = 'P';
for (const auto PieceIt : mPieces)
{
PieceInfo* Info = PieceIt.second;
if (strncmp(Name, Info->m_strName, strlen(Name)) == 0)
Pieces.Add(Info);
}
if (strncmp(Name, PieceIt.first.c_str(), strlen(Name)) == 0)
Pieces.Add(PieceIt.second);
}
}

View file

@ -51,15 +51,14 @@ static bool lcLoadLDrawXML(std::map<int, int>& MaterialTable, std::map<int, std:
}
else if (ElementName == QLatin1String("Brick"))
{
QString LDrawID = Element.attribute(QLatin1String("ldraw")).toUpper();
LDrawID.chop(4);
QString LDrawID = Element.attribute(QLatin1String("ldraw"));
int LegoID = Element.attribute(QLatin1String("lego")).toInt();
BrickTable.insert(std::make_pair(LegoID, std::move(LDrawID.toStdString())));
}
else if (ElementName == QLatin1String("Transformation"))
{
QString LDrawID = Element.attribute(QLatin1String("ldraw")).toUpper();
QString LDrawID = Element.attribute(QLatin1String("ldraw"));
LDrawID.chop(4);
lcVector3 Translation;
@ -163,7 +162,7 @@ bool lcImportLXFMLFile(const QString& FileData, lcArray<lcPiece*>& Pieces, lcArr
if (BrickIt != BrickTable.end())
Info = lcGetPiecesLibrary()->FindPiece(BrickIt->second.c_str(), nullptr, true, false);
else
Info = lcGetPiecesLibrary()->FindPiece(LegoID.toLatin1(), nullptr, true, false);
Info = lcGetPiecesLibrary()->FindPiece(LegoID.toLatin1() + ".dat", nullptr, true, false);
const auto ColorIt = MaterialTable.find(Material);
int ColorCode = 16;

View file

@ -224,7 +224,7 @@ void lcModel::DeleteModel()
void lcModel::CreatePieceInfo(Project* Project)
{
lcPiecesLibrary* Library = lcGetPiecesLibrary();
mPieceInfo = Library->FindPiece(mProperties.mName.toUpper().toLatin1().constData(), Project, true, false);
mPieceInfo = Library->FindPiece(mProperties.mName.toLatin1().constData(), Project, true, false);
mPieceInfo->SetModel(this, true, Project, true);
Library->LoadPieceInfo(mPieceInfo, true, true);
}
@ -621,15 +621,9 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
lcMatrix44 IncludeTransform(lcVector4(IncludeMatrix[3], IncludeMatrix[6], IncludeMatrix[9], 0.0f), lcVector4(IncludeMatrix[4], IncludeMatrix[7], IncludeMatrix[10], 0.0f),
lcVector4(IncludeMatrix[5], IncludeMatrix[8], IncludeMatrix[11], 0.0f), lcVector4(IncludeMatrix[0], IncludeMatrix[1], IncludeMatrix[2], 1.0f));
QString OriginalID = LineStream.readAll().trimmed();
QString File = OriginalID.toUpper();
QString PartID = File;
PartID.replace('\\', '/');
QByteArray PartID = LineStream.readAll().trimmed().toLatin1();
if (PartID.endsWith(QLatin1String(".DAT")))
PartID = PartID.left(PartID.size() - 4);
if (Library->IsPrimitive(PartID.toLatin1().constData()))
if (Library->IsPrimitive(PartID.constData()))
{
mFileLines.append(OriginalLine);
}
@ -641,17 +635,14 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
if (!CurrentGroups.IsEmpty())
Piece->SetGroup(CurrentGroups[CurrentGroups.GetSize() - 1]);
PieceInfo* Info = Library->FindPiece(PartID.toLatin1().constData(), Project, false, true);
if (!Info)
Info = Library->FindPiece(File.toLatin1().constData(), Project, true, true);
PieceInfo* Info = Library->FindPiece(PartID.constData(), Project, true, true);
float* Matrix = IncludeTransform;
lcMatrix44 Transform(lcVector4(Matrix[0], Matrix[2], -Matrix[1], 0.0f), lcVector4(Matrix[8], Matrix[10], -Matrix[9], 0.0f),
lcVector4(-Matrix[4], -Matrix[6], Matrix[5], 0.0f), lcVector4(Matrix[12], Matrix[14], -Matrix[13], 1.0f));
Piece->SetFileLine(mFileLines.size());
Piece->SetPieceInfo(Info, OriginalID, false);
Piece->SetPieceInfo(Info, PartID, false);
Piece->Initialize(Transform, CurrentStep);
Piece->SetColorCode(ColorCode);
Piece->SetControlPoints(ControlPoints);
@ -743,6 +734,7 @@ bool lcModel::LoadBinary(lcFile* file)
file->ReadFloats(rot, 3);
file->ReadU8(&color, 1);
file->ReadBuffer(name, 9);
strcat(name, ".dat");
file->ReadU8(&step, 1);
file->ReadU8(&group, 1);
@ -1427,21 +1419,7 @@ void lcModel::LoadCheckPoint(lcModelHistoryEntry* CheckPoint)
void lcModel::SetActive(bool Active)
{
if (Active)
{
CalculateStep(mCurrentStep);
}
else
{
CalculateStep(LC_STEP_MAX);
strncpy(mPieceInfo->m_strName, mProperties.mName.toLatin1().constData(), sizeof(mPieceInfo->m_strName));
strupr(mPieceInfo->m_strName);
mPieceInfo->m_strName[sizeof(mPieceInfo->m_strName) - 1] = 0;
strncpy(mPieceInfo->m_strDescription, mProperties.mName.toLatin1().constData(), sizeof(mPieceInfo->m_strDescription));
mPieceInfo->m_strDescription[sizeof(mPieceInfo->m_strDescription) - 1] = 0;
}
CalculateStep(Active ? mCurrentStep : LC_STEP_MAX);
mActive = Active;
}

View file

@ -219,7 +219,7 @@ void lcPartSelectionListModel::SetFilter(const QString& Filter)
Dst++;
}
Visible = strcasestr(Description, mFilter) || strcasestr(Info->m_strName, mFilter);
Visible = strcasestr(Description, mFilter) || strcasestr(Info->mFileName, mFilter);
}
mListView->setRowHidden(PartIdx, !Visible);
@ -249,7 +249,7 @@ QVariant lcPartSelectionListModel::data(const QModelIndex& Index, int Role) cons
break;
case Qt::ToolTipRole:
return QVariant(QString("%1 (%2)").arg(QString::fromLatin1(Info->m_strDescription), QString::fromLatin1(Info->m_strName)));
return QVariant(QString("%1 (%2)").arg(QString::fromLatin1(Info->m_strDescription), QString::fromLatin1(Info->mFileName)));
case Qt::DecorationRole:
if (!mParts[InfoIndex].second.isNull() && mIconSize)
@ -555,7 +555,7 @@ void lcPartSelectionListView::startDrag(Qt::DropActions SupportedActions)
QByteArray ItemData;
QDataStream DataStream(&ItemData, QIODevice::WriteOnly);
DataStream << QString(Info->m_strName);
DataStream << QString(Info->mFileName);
QMimeData* MimeData = new QMimeData;
MimeData->setData("application/vnd.leocad-part", ItemData);

View file

@ -20,29 +20,29 @@ void lcSynthInit()
lcHoseInfo HoseInfo[] =
{
{ "72504", lcSynthType::RIBBED_HOSE, 31.25f, 4 }, // Technic Ribbed Hose 2L
{ "72706", lcSynthType::RIBBED_HOSE, 50.00f, 7 }, // Technic Ribbed Hose 3L
{ "71952", lcSynthType::RIBBED_HOSE, 75.00f, 11 }, // Technic Ribbed Hose 4L
{ "71944", lcSynthType::RIBBED_HOSE, 112.50f, 17 }, // Technic Ribbed Hose 6L
{ "71951", lcSynthType::RIBBED_HOSE, 143.75f, 22 }, // Technic Ribbed Hose 8L
{ "71986", lcSynthType::RIBBED_HOSE, 212.50f, 33 }, // Technic Ribbed Hose 11L
{ "43675", lcSynthType::RIBBED_HOSE, 375.00f, 58 }, // Technic Ribbed Hose 19L
{ "32580", lcSynthType::FLEXIBLE_AXLE, 120.00f, 15 }, // Technic Axle Flexible 7
{ "32199", lcSynthType::FLEXIBLE_AXLE, 200.00f, 35 }, // Technic Axle Flexible 11
{ "55709", lcSynthType::FLEXIBLE_AXLE, 200.00f, 35 }, // Technic Axle Flexible 11
{ "32200", lcSynthType::FLEXIBLE_AXLE, 220.00f, 40 }, // Technic Axle Flexible 12
{ "32201", lcSynthType::FLEXIBLE_AXLE, 260.00f, 50 }, // Technic Axle Flexible 14
{ "32202", lcSynthType::FLEXIBLE_AXLE, 300.00f, 60 }, // Technic Axle Flexible 16
{ "32235", lcSynthType::FLEXIBLE_AXLE, 360.00f, 75 }, // Technic Axle Flexible 19
{ "76384", lcSynthType::STRING_BRAIDED, 200.00f, 46 }, // String Braided 11L with End Studs
{ "75924", lcSynthType::STRING_BRAIDED, 400.00f, 96 }, // String Braided 21L with End Studs
{ "572C02", lcSynthType::STRING_BRAIDED, 800.00f, 196 }, // String Braided 41L with End Studs
{ "73129", lcSynthType::SHOCK_ABSORBER, 110.00f, 1 }, // Technic Shock Absorber 6.5L
{ "41838", lcSynthType::SHOCK_ABSORBER, 110.00f, 1 }, // Technic Shock Absorber 6.5L Soft
{ "76138", lcSynthType::SHOCK_ABSORBER, 110.00f, 1 }, // Technic Shock Absorber 6.5L Stiff
{ "76537", lcSynthType::SHOCK_ABSORBER, 110.00f, 1 }, // Technic Shock Absorber 6.5L Extra Stiff
{ "61927C01", lcSynthType::ACTUATOR, 270.00f, 1 }, // Technic Power Functions Linear Actuator (Extended)
{ "61927", lcSynthType::ACTUATOR, 170.00f, 1 } // Technic Power Functions Linear Actuator (Contracted)
{ "72504.dat", lcSynthType::RIBBED_HOSE, 31.25f, 4 }, // Technic Ribbed Hose 2L
{ "72706.dat", lcSynthType::RIBBED_HOSE, 50.00f, 7 }, // Technic Ribbed Hose 3L
{ "71952.dat", lcSynthType::RIBBED_HOSE, 75.00f, 11 }, // Technic Ribbed Hose 4L
{ "71944.dat", lcSynthType::RIBBED_HOSE, 112.50f, 17 }, // Technic Ribbed Hose 6L
{ "71951.dat", lcSynthType::RIBBED_HOSE, 143.75f, 22 }, // Technic Ribbed Hose 8L
{ "71986.dat", lcSynthType::RIBBED_HOSE, 212.50f, 33 }, // Technic Ribbed Hose 11L
{ "43675.dat", lcSynthType::RIBBED_HOSE, 375.00f, 58 }, // Technic Ribbed Hose 19L
{ "32580.dat", lcSynthType::FLEXIBLE_AXLE, 120.00f, 15 }, // Technic Axle Flexible 7
{ "32199.dat", lcSynthType::FLEXIBLE_AXLE, 200.00f, 35 }, // Technic Axle Flexible 11
{ "55709.dat", lcSynthType::FLEXIBLE_AXLE, 200.00f, 35 }, // Technic Axle Flexible 11
{ "32200.dat", lcSynthType::FLEXIBLE_AXLE, 220.00f, 40 }, // Technic Axle Flexible 12
{ "32201.dat", lcSynthType::FLEXIBLE_AXLE, 260.00f, 50 }, // Technic Axle Flexible 14
{ "32202.dat", lcSynthType::FLEXIBLE_AXLE, 300.00f, 60 }, // Technic Axle Flexible 16
{ "32235.dat", lcSynthType::FLEXIBLE_AXLE, 360.00f, 75 }, // Technic Axle Flexible 19
{ "76384.dat", lcSynthType::STRING_BRAIDED, 200.00f, 46 }, // String Braided 11L with End Studs
{ "75924.dat", lcSynthType::STRING_BRAIDED, 400.00f, 96 }, // String Braided 21L with End Studs
{ "572C02.dat", lcSynthType::STRING_BRAIDED, 800.00f, 196 }, // String Braided 41L with End Studs
{ "73129.dat", lcSynthType::SHOCK_ABSORBER, 110.00f, 1 }, // Technic Shock Absorber 6.5L
{ "41838.dat", lcSynthType::SHOCK_ABSORBER, 110.00f, 1 }, // Technic Shock Absorber 6.5L Soft
{ "76138.dat", lcSynthType::SHOCK_ABSORBER, 110.00f, 1 }, // Technic Shock Absorber 6.5L Stiff
{ "76537.dat", lcSynthType::SHOCK_ABSORBER, 110.00f, 1 }, // Technic Shock Absorber 6.5L Extra Stiff
{ "61927C01.dat", lcSynthType::ACTUATOR, 270.00f, 1 }, // Technic Power Functions Linear Actuator (Extended)
{ "61927.dat", lcSynthType::ACTUATOR, 170.00f, 1 } // Technic Power Functions Linear Actuator (Contracted)
};
for (unsigned int InfoIdx = 0; InfoIdx < sizeof(HoseInfo) / sizeof(HoseInfo[0]); InfoIdx++)
@ -345,7 +345,7 @@ void lcSynthInfo::AddRibbedHoseParts(lcMemFile& File, const lcArray<lcMatrix44>&
lcMatrix33 Transform(lcMul(lcMatrix33Scale(lcVector3(1.0f, -1.0f, 1.0f)), lcMatrix33(Sections[SectionIdx])));
lcVector3 Offset = Sections[SectionIdx].GetTranslation();
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 79.DAT\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 79.dat\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
Transform[0][1], Transform[1][1], Transform[2][1], Transform[0][2], Transform[1][2], Transform[2][2]);
File.WriteBuffer(Line, strlen(Line));
@ -355,7 +355,7 @@ void lcSynthInfo::AddRibbedHoseParts(lcMemFile& File, const lcArray<lcMatrix44>&
{
const lcMatrix44& Transform = Sections[SectionIdx];
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 80.DAT\n", Transform[3][0], Transform[3][1], Transform[3][2], Transform[0][0], Transform[1][0], Transform[2][0],
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 80.dat\n", Transform[3][0], Transform[3][1], Transform[3][2], Transform[0][0], Transform[1][0], Transform[2][0],
Transform[0][1], Transform[1][1], Transform[2][1], Transform[0][2], Transform[1][2], Transform[2][2]);
File.WriteBuffer(Line, strlen(Line));
@ -366,7 +366,7 @@ void lcSynthInfo::AddRibbedHoseParts(lcMemFile& File, const lcArray<lcMatrix44>&
lcMatrix33 Transform(Sections[SectionIdx]);
lcVector3 Offset = lcMul31(lcVector3(0.0f, -6.25f, 0.0f), Sections[SectionIdx]);
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 79.DAT\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 79.dat\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
Transform[0][1], Transform[1][1], Transform[2][1], Transform[0][2], Transform[1][2], Transform[2][2]);
File.WriteBuffer(Line, strlen(Line));
@ -390,7 +390,7 @@ void lcSynthInfo::AddFlexibleAxleParts(lcMemFile& File, lcLibraryMeshData& MeshD
const char* EdgeParts[6] =
{
"STUD3A.DAT", "S/FAXLE1.DAT", "S/FAXLE2.DAT", "S/FAXLE3.DAT", "S/FAXLE4.DAT", "S/FAXLE5.DAT"
"stud3a.dat", "s/faxle1.dat", "s/faxle2.dat", "s/faxle3.dat", "s/faxle4.dat", "s/faxle5.dat"
};
for (int PartIdx = 0; PartIdx < NumEdgeParts; PartIdx++)
@ -491,7 +491,7 @@ void lcSynthInfo::AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& Mesh
lcMatrix33 Transform(Sections[SectionIdx]);
lcVector3 Offset = lcMul31(lcVector3(-8.0f, 0.0f, 0.0f), Sections[SectionIdx]);
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 572A.DAT\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 572A.dat\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
Transform[0][1], Transform[1][1], Transform[2][1], Transform[0][2], Transform[1][2], Transform[2][2]);
File.WriteBuffer(Line, strlen(Line));
@ -594,7 +594,7 @@ void lcSynthInfo::AddStringBraidedParts(lcMemFile& File, lcLibraryMeshData& Mesh
lcMatrix33 Transform(Sections[SectionIdx]);
lcVector3 Offset = lcMul31(lcVector3(8.0f, 0.0f, 0.0f), Sections[SectionIdx]);
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 572A.DAT\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
sprintf(Line, "1 16 %f %f %f %f %f %f %f %f %f %f %f %f 572A.dat\n", Offset[0], Offset[1], Offset[2], Transform[0][0], Transform[1][0], Transform[2][0],
Transform[0][1], Transform[1][1], Transform[2][1], Transform[0][2], Transform[1][2], Transform[2][2]);
File.WriteBuffer(Line, strlen(Line));
@ -607,30 +607,30 @@ void lcSynthInfo::AddShockAbsorberParts(lcMemFile& File, lcArray<lcMatrix44>& Se
lcVector3 Offset;
Offset = Sections[0].GetTranslation();
sprintf(Line, "1 0 %f %f %f 1 0 0 0 1 0 0 0 1 4254.DAT\n", Offset[0], Offset[1], Offset[2]);
sprintf(Line, "1 0 %f %f %f 1 0 0 0 1 0 0 0 1 4254.dat\n", Offset[0], Offset[1], Offset[2]);
File.WriteBuffer(Line, strlen(Line));
Offset = Sections[1].GetTranslation();
sprintf(Line, "1 16 %f %f %f 1 0 0 0 1 0 0 0 1 4255.DAT\n", Offset[0], Offset[1], Offset[2]);
sprintf(Line, "1 16 %f %f %f 1 0 0 0 1 0 0 0 1 4255.dat\n", Offset[0], Offset[1], Offset[2]);
File.WriteBuffer(Line, strlen(Line));
float Distance = Sections[0].GetTranslation().y - Sections[1].GetTranslation().y;
float Scale = (Distance - 66.0f) / 44.0f;
const char* SpringPart;
if (!strcmp(mPieceInfo->m_strName, "73129"))
if (!stricmp(mPieceInfo->mFileName, "73129.dat"))
SpringPart = "70038";
else if (!strcmp(mPieceInfo->m_strName, "41838"))
else if (!stricmp(mPieceInfo->mFileName, "41838"))
SpringPart = "41837";
else if (!strcmp(mPieceInfo->m_strName, "76138"))
else if (!stricmp(mPieceInfo->mFileName, "76138"))
SpringPart = "71953";
else if (!strcmp(mPieceInfo->m_strName, "76537"))
else if (!stricmp(mPieceInfo->mFileName, "76537"))
SpringPart = "22977";
else
return;
Offset = Sections[0].GetTranslation();
sprintf(Line, "1 494 %f %f %f 1 0 0 0 %f 0 0 0 1 %s.DAT\n", Offset[0], Offset[1] - 10 - 44.0f * Scale, Offset[2], Scale, SpringPart);
sprintf(Line, "1 494 %f %f %f 1 0 0 0 %f 0 0 0 1 %s.dat\n", Offset[0], Offset[1] - 10 - 44.0f * Scale, Offset[2], Scale, SpringPart);
File.WriteBuffer(Line, strlen(Line));
}
@ -640,13 +640,13 @@ void lcSynthInfo::AddActuatorParts(lcMemFile& File, lcArray<lcMatrix44>& Section
lcVector3 Offset;
Offset = Sections[0].GetTranslation();
sprintf(Line, "1 25 %f %f %f 0 1 0 -1 0 0 0 0 1 47157.DAT\n", Offset[0], Offset[1], Offset[2]);
sprintf(Line, "1 25 %f %f %f 0 1 0 -1 0 0 0 0 1 47157.dat\n", Offset[0], Offset[1], Offset[2]);
File.WriteBuffer(Line, strlen(Line));
sprintf(Line, "1 16 %f %f %f 1 0 0 0 1 0 0 0 1 62271c01.DAT\n", Offset[0], Offset[1], Offset[2]);
sprintf(Line, "1 16 %f %f %f 1 0 0 0 1 0 0 0 1 62271c01.dat\n", Offset[0], Offset[1], Offset[2]);
File.WriteBuffer(Line, strlen(Line));
Offset = Sections[1].GetTranslation();
sprintf(Line, "1 72 %f %f %f 1 0 0 0 1 0 0 0 1 62274c01.DAT\n", Offset[0], Offset[1], Offset[2]);
sprintf(Line, "1 72 %f %f %f 1 0 0 0 1 0 0 0 1 62274c01.dat\n", Offset[0], Offset[1], Offset[2]);
File.WriteBuffer(Line, strlen(Line));
}

View file

@ -53,7 +53,7 @@ void MinifigWizard::OnInitialUpdate()
memset(&mMinifig, 0, sizeof(lcMinifig));
const int ColorCodes[LC_MFW_NUMITEMS] = { 4, 7, 14, 7, 1, 0, 7, 4, 4, 14, 14, 7, 7, 0, 0, 7, 7 };
const char* Pieces[LC_MFW_NUMITEMS] = { "3624", "None", "3626BP01", "None", "973", "3815", "None", "3819", "3818", "3820", "3820", "None", "None", "3817", "3816", "None", "None" };
const char* Pieces[LC_MFW_NUMITEMS] = { "3624.dat", "", "3626bp01.dat", "", "973.dat", "3815.dat", "", "3819.dat", "3818.dat", "3820.dat", "3820.dat", "", "", "3817.dat", "3816.dat", "", "" };
lcPiecesLibrary* Library = lcGetPiecesLibrary();
for (int i = 0; i < LC_MFW_NUMITEMS; i++)
@ -165,14 +165,6 @@ void MinifigWizard::ParseSettings(lcFile& Settings)
*NameEnd = 0;
NameEnd++;
strupr(NameStart);
char* Ext = strrchr(NameStart, '.');
if (Ext != nullptr)
{
if (!strcmp(Ext, ".DAT"))
*Ext = 0;
}
PieceInfo* Info = lcGetPiecesLibrary()->FindPiece(NameStart, nullptr, false, false);
if (!Info && *NameStart)
continue;
@ -372,8 +364,8 @@ void MinifigWizard::Calculate()
float* Angles = mMinifig.Angles;
lcMatrix44* Matrices = mMinifig.Matrices;
bool DroidTorso = Parts[LC_MFW_BODY] && !strcmp(Parts[LC_MFW_BODY]->m_strName, "30375");
bool SkeletonTorso = Parts[LC_MFW_BODY] && !strcmp(Parts[LC_MFW_BODY]->m_strName, "6260");
bool DroidTorso = Parts[LC_MFW_BODY] && !stricmp(Parts[LC_MFW_BODY]->mFileName, "30375.dat");
bool SkeletonTorso = Parts[LC_MFW_BODY] && !stricmp(Parts[LC_MFW_BODY]->mFileName, "6260.dat");
if (Parts[LC_MFW_BODY3])
Root = lcMatrix44Translation(lcVector3(0, 0, 74.0f));

View file

@ -78,7 +78,7 @@ void lcPiece::SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait)
if (!ID.isEmpty())
mID = ID;
else if (mPieceInfo)
mID = mPieceInfo->GetSaveID();
mID = mPieceInfo->mFileName;
else
mID.clear();
@ -97,7 +97,7 @@ void lcPiece::SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait)
void lcPiece::UpdateID()
{
mID = mPieceInfo->GetSaveID();
mID = mPieceInfo->mFileName;
}
void lcPiece::SaveLDraw(QTextStream& Stream) const
@ -303,6 +303,7 @@ bool lcPiece::FileLoad(lcFile& file)
}
else
file.ReadBuffer(name, LC_PIECE_NAME_LEN);
strcat(name, ".dat");
PieceInfo* pInfo = lcGetPiecesLibrary()->FindPiece(name, nullptr, true, false);
SetPieceInfo(pInfo, QString(), true);

View file

@ -34,14 +34,6 @@ PieceInfo::~PieceInfo()
Unload();
}
QString PieceInfo::GetSaveID() const
{
if (mFlags & (LC_PIECE_MODEL | LC_PIECE_PROJECT))
return QString::fromLatin1(m_strName);
return QString::fromLatin1(m_strName) + QLatin1String(".dat");
}
void PieceInfo::SetMesh(lcMesh* Mesh)
{
mBoundingBox = Mesh->mBoundingBox;
@ -68,8 +60,8 @@ void PieceInfo::SetModel(lcModel* Model, bool UpdateMesh, Project* CurrentProjec
mModel = Model;
}
strncpy(m_strName, Model->GetProperties().mName.toUpper().toLatin1().data(), sizeof(m_strName));
m_strName[sizeof(m_strName)-1] = 0;
strncpy(mFileName, Model->GetProperties().mName.toLatin1().data(), sizeof(mFileName));
mFileName[sizeof(mFileName)-1] = 0;
strncpy(m_strDescription, Model->GetProperties().mName.toLatin1().data(), sizeof(m_strDescription));
m_strDescription[sizeof(m_strDescription)-1] = 0;
@ -97,7 +89,7 @@ void PieceInfo::SetModel(lcModel* Model, bool UpdateMesh, Project* CurrentProjec
}
}
void PieceInfo::SetProject(Project* Project, const char* PieceName)
void PieceInfo::CreateProject(Project* Project, const char* PieceName)
{
if (mProject != Project)
{
@ -106,10 +98,10 @@ void PieceInfo::SetProject(Project* Project, const char* PieceName)
mState = LC_PIECEINFO_LOADED;
}
strncpy(m_strName, PieceName, sizeof(m_strName));
m_strName[sizeof(m_strName)-1] = 0;
strncpy(mFileName, PieceName, sizeof(mFileName));
mFileName[sizeof(mFileName) - 1] = 0;
strncpy(m_strDescription, Project->GetFileName().toLatin1().data(), sizeof(m_strDescription));
m_strDescription[sizeof(m_strDescription)-1] = 0;
m_strDescription[sizeof(m_strDescription) - 1] = 0;
}
bool PieceInfo::IncludesModel(const lcModel* Model) const
@ -127,10 +119,10 @@ bool PieceInfo::IncludesModel(const lcModel* Model) const
void PieceInfo::CreatePlaceholder(const char* Name)
{
strncpy(m_strName, Name, sizeof(m_strName));
m_strName[sizeof(m_strName)-1] = 0;
strncpy(mFileName, Name, sizeof(mFileName));
mFileName[sizeof(mFileName) - 1] = 0;
strncpy(m_strDescription, Name, sizeof(m_strDescription));
m_strDescription[sizeof(m_strDescription)-1] = 0;
m_strDescription[sizeof(m_strDescription) - 1] = 0;
SetPlaceholder();
}

View file

@ -30,8 +30,6 @@ public:
PieceInfo();
~PieceInfo();
QString GetSaveID() const;
const lcBoundingBox& GetBoundingBox() const
{
return mBoundingBox;
@ -110,7 +108,7 @@ public:
bool IsPatterned() const
{
const char* Name = m_strName;
const char* Name = mFileName;
while (*Name)
{
@ -120,7 +118,7 @@ public:
Name++;
}
if (*Name == 'P')
if (*Name == 'P' || *Name == 'p')
return true;
return false;
@ -139,7 +137,7 @@ public:
void SetPlaceholder();
void SetModel(lcModel* Model, bool UpdateMesh, Project* CurrentProject, bool SearchProjectFolder);
void SetProject(Project* Project, const char* PieceName);
void CreateProject(Project* Project, const char* PieceName);
bool IncludesModel(const lcModel* Model) const;
bool MinIntersectDist(const lcVector3& Start, const lcVector3& End, float& MinDistance) const;
bool BoxTest(const lcMatrix44& WorldMatrix, const lcVector4 Planes[6]) const;
@ -151,7 +149,7 @@ public:
void Unload();
public:
char m_strName[LC_PIECE_NAME_LEN];
char mFileName[LC_PIECE_NAME_LEN];
char m_strDescription[128];
int mZipFileType;
int mZipFileIndex;

View file

@ -219,7 +219,7 @@ void Project::ShowModelListDialog()
else if (Model->GetProperties().mName != it->first)
{
Model->SetName(it->first);
lcGetPiecesLibrary()->RenamePiece(Model->GetPieceInfo(), it->first.toUpper().toLatin1().constData());
lcGetPiecesLibrary()->RenamePiece(Model->GetPieceInfo(), it->first.toLatin1().constData());
for (lcModel* CheckModel : mModels)
CheckModel->RenamePiece(Model->GetPieceInfo());
@ -981,7 +981,13 @@ void Project::ExportBrickLink()
BrickLinkFile.WriteLine(" <ITEM>\n");
BrickLinkFile.WriteLine(" <ITEMTYPE>P</ITEMTYPE>\n");
sprintf(Line, " <ITEMID>%s</ITEMID>\n", Info->m_strName);
char FileName[LC_PIECE_NAME_LEN];
strcpy(FileName, Info->mFileName);
char* Ext = strchr(FileName, '.');
if (Ext)
*Ext = 0;
sprintf(Line, " <ITEMID>%s</ITEMID>\n", FileName);
BrickLinkFile.WriteLine(Line);
int Count = ColorIt.second;
@ -1040,7 +1046,7 @@ void Project::ExportCSV()
for (const auto& ColorIt : PartIt.second)
{
sprintf(Line, "\"%s\",\"%s\",%d,%s,%d\n", Info->m_strDescription, gColorList[ColorIt.first].Name, ColorIt.second, Info->m_strName, gColorList[ColorIt.first].Code);
sprintf(Line, "\"%s\",\"%s\",%d,%s,%d\n", Info->m_strDescription, gColorList[ColorIt.first].Name, ColorIt.second, Info->mFileName, gColorList[ColorIt.first].Code);
CSVFile.WriteLine(Line);
}
}
@ -1269,7 +1275,7 @@ void Project::CreateHTMLPieceList(QTextStream& Stream, lcModel* Model, lcStep St
const PieceInfo* Info = PartIt.first;
if (Images)
Stream << QString("<tr><td><IMG SRC=\"%1.png\" ALT=\"%2\"></td>\n").arg(Info->m_strName, Info->m_strDescription);
Stream << QString("<tr><td><IMG SRC=\"%1.png\" ALT=\"%2\"></td>\n").arg(Info->mFileName, Info->m_strDescription);
else
Stream << QString("<tr><td>%1</td>\r\n").arg(Info->m_strDescription);
@ -1565,7 +1571,7 @@ void Project::ExportHTML()
Scene.Draw(Context);
QString FileName = QFileInfo(Dir, QLatin1String(Info->m_strName) + QLatin1String(".png")).absoluteFilePath();
QString FileName = QFileInfo(Dir, QLatin1String(Info->mFileName) + QLatin1String(".png")).absoluteFilePath();
if (!Context->SaveRenderToTextureImage(FileName, Width, Height))
break;
}
@ -1683,7 +1689,7 @@ void Project::ExportPOVRay()
if (sscanf(Line,"%s%s%s", Src, Dst, Flags) != 3)
continue;
strupr(Src);
strcat(Src, ".dat");
PieceInfo* Info = Library->FindPiece(Src, nullptr, false, false);
if (!Info)
@ -1815,9 +1821,11 @@ void Project::ExportPOVRay()
char Name[LC_PIECE_NAME_LEN];
char* Ptr;
strcpy(Name, Info->m_strName);
strcpy(Name, Info->mFileName);
while ((Ptr = strchr(Name, '-')))
*Ptr = '_';
while ((Ptr = strchr(Name, '.')))
*Ptr = '_';
sprintf(Entry.first, "lc_%s", Name);

View file

@ -256,7 +256,7 @@ void lcQPreferencesDialog::updateParts()
PieceInfo *info = singleParts[partIndex];
QStringList rowList(info->m_strDescription);
rowList.append(info->m_strName);
rowList.append(info->mFileName);
new QTreeWidgetItem(tree, rowList);
}
@ -276,7 +276,7 @@ void lcQPreferencesDialog::updateParts()
if (categoryIndex == options->Categories.GetSize())
{
QStringList rowList(Info->m_strDescription);
rowList.append(Info->m_strName);
rowList.append(Info->mFileName);
new QTreeWidgetItem(tree, rowList);
}