From 5ffe86ae21fb973f03544ac2f52a5fe80e870e6f Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 8 Feb 2012 22:48:51 +0000 Subject: [PATCH] Fixed decimal point when saving text files. --- common/library.h | 2 -- common/minifig.cpp | 25 ++++++++++++++++++ common/minifig.h | 3 ++- common/project.cpp | 64 +++++++++++++++++++++++++--------------------- 4 files changed, 62 insertions(+), 32 deletions(-) diff --git a/common/library.h b/common/library.h index a78c02fd..9fe30501 100755 --- a/common/library.h +++ b/common/library.h @@ -101,8 +101,6 @@ protected: int m_nMovedCount; // number of moved pieces char* m_pMovedReference; // moved pieces list - int m_nPieceCount; // number of pieces - PieceInfo* m_pPieceIdx; // pieces array int m_nTextureCount; // number of textures Texture* m_pTextures; // textures array diff --git a/common/minifig.cpp b/common/minifig.cpp index 7f4e0df4..205743b6 100644 --- a/common/minifig.cpp +++ b/common/minifig.cpp @@ -862,6 +862,27 @@ MinifigWizard::MinifigWizard (GLWindow *share) Sys_MessageBox ("Unknown Minifig Preferences."); } +void MinifigWizard::OnInitialUpdate() +{ + const unsigned char colors[LC_MFW_NUMITEMS] = { 0, 6, 4, 22, 0, 0, 6, 6, 22, 22, 9, 9, 9, 22, 22 }; + const char *pieces[LC_MFW_NUMITEMS] = { "3624", "3626BP01", "973", "None", "3819", "3818", "3820", "3820", + "None", "None", "3815", "3817", "3816", "None", "None" }; + + MakeCurrent(); + + for (int i = 0; i < LC_MFW_NUMITEMS; i++) + { + m_Colors[i] = colors[i]; + m_Angles[i] = 0; + + m_Info[i] = lcGetPiecesLibrary()->FindPieceInfo(pieces[i]); + if (m_Info[i] != NULL) + m_Info[i]->AddRef(); + } + + Calculate(); +} + MinifigWizard::~MinifigWizard () { char *ptr, buf[32]; @@ -905,6 +926,10 @@ MinifigWizard::~MinifigWizard () free (m_MinifigNames); free (m_MinifigTemplates); + + for (i = 0; i < LC_MFW_NUMITEMS; i++) + if (m_Info[i]) + m_Info[i]->DeRef(); } void MinifigWizard::ParseSettings(File& Settings) diff --git a/common/minifig.h b/common/minifig.h index a73b3fed..73357ddb 100644 --- a/common/minifig.h +++ b/common/minifig.h @@ -30,7 +30,7 @@ enum LC_MFW_TYPES struct lcMinifigPieceInfo { - char Description[80]; + char Description[128]; PieceInfo* Info; Matrix44 Offset; }; @@ -42,6 +42,7 @@ public: ~MinifigWizard (); void OnDraw (); + void OnInitialUpdate(); void Calculate(); int GetSelectionIndex(int Type) const; diff --git a/common/project.cpp b/common/project.cpp index f6137fc8..6a0cb6f6 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -1276,6 +1276,8 @@ bool Project::DoSave(char* lpszPathName, bool bReplace) strcat(buf, "\r\n"); file.Write(buf, strlen(buf)); + const char* OldLocale = setlocale(LC_NUMERIC, "C"); + for (i = 1; i <= steps; i++) { for (pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext) @@ -1297,9 +1299,12 @@ bool Project::DoSave(char* lpszPathName, bool bReplace) file.Write("0 STEP\r\n", 8); } file.Write("0\r\n", 3); + + setlocale(LC_NUMERIC, OldLocale); } else FileSave(&file, false); // save me + file.Close(); SetModifiedFlag(false); // back to unmodified @@ -3955,6 +3960,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) break; } + const char* OldLocale = setlocale(LC_NUMERIC, "C"); fputs("// Stuff that doesn't need to be changed\n\n", f); if (strlen(opts.libpath)) @@ -4147,6 +4153,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) if (!f) { SystemDoMessageBox("Could not open file for writing.", LC_MB_OK|LC_MB_ICONERROR); + setlocale(LC_NUMERIC, OldLocale); break; } @@ -4212,6 +4219,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) fclose (f); free (conv); free (flags); + setlocale(LC_NUMERIC, OldLocale); if (opts.render) { @@ -4847,36 +4855,36 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) case LC_PIECE_MINIFIG: { - MinifigWizard *wiz = new MinifigWizard (m_ViewList[0]); - int i; + MinifigWizard Wizard(m_ActiveView); + int i; - if (SystemDoDialog (LC_DLG_MINIFIG, wiz)) - { - SelectAndFocusNone(false); + if (SystemDoDialog(LC_DLG_MINIFIG, &Wizard)) + { + SelectAndFocusNone(false); - for (i = 0; i < LC_MFW_NUMITEMS; i++) - { - if (wiz->m_Info[i] == NULL) - continue; + for (i = 0; i < LC_MFW_NUMITEMS; i++) + { + if (Wizard.m_Info[i] == NULL) + continue; - Matrix mat; - Piece* pPiece = new Piece(wiz->m_Info[i]); + Matrix mat; + Piece* pPiece = new Piece(Wizard.m_Info[i]); - Vector4& Position = wiz->m_Matrices[i][3]; - Vector4 Rotation = wiz->m_Matrices[i].ToAxisAngle(); - Rotation[3] *= LC_RTOD; - pPiece->Initialize(Position[0], Position[1], Position[2], m_nCurStep, m_nCurFrame, wiz->m_Colors[i]); - pPiece->CreateName(m_pPieces); - AddPiece(pPiece); - pPiece->Select(true, false, false); + Vector4& Position = Wizard.m_Matrices[i][3]; + Vector4 Rotation = Wizard.m_Matrices[i].ToAxisAngle(); + Rotation[3] *= LC_RTOD; + pPiece->Initialize(Position[0], Position[1], Position[2], m_nCurStep, m_nCurFrame, Wizard.m_Colors[i]); + pPiece->CreateName(m_pPieces); + AddPiece(pPiece); + pPiece->Select(true, false, false); - pPiece->ChangeKey(1, false, false, Rotation, LC_PK_ROTATION); - pPiece->ChangeKey(1, true, false, Rotation, LC_PK_ROTATION); - pPiece->UpdatePosition(m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation); - pPiece->CalculateConnections(m_pConnections, m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, false, true); + pPiece->ChangeKey(1, false, false, Rotation, LC_PK_ROTATION); + pPiece->ChangeKey(1, true, false, Rotation, LC_PK_ROTATION); + pPiece->UpdatePosition(m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation); + pPiece->CalculateConnections(m_pConnections, m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, false, true); - SystemPieceComboAdd(wiz->m_Info[i]->m_strDescription); - } + SystemPieceComboAdd(Wizard.m_Info[i]->m_strDescription); + } float bs[6] = { 10000, 10000, 10000, -10000, -10000, -10000 }; int max = 0; @@ -4904,16 +4912,12 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam) pGroup->m_fCenter[1] = (bs[1]+bs[4])/2; pGroup->m_fCenter[2] = (bs[2]+bs[5])/2; - messenger->Dispatch (LC_MSG_FOCUS_CHANGED, NULL); + messenger->Dispatch (LC_MSG_FOCUS_CHANGED, NULL); UpdateSelection(); UpdateAllViews(); SetModifiedFlag(true); CheckPoint("Minifig"); } - - for (i = 0; i < LC_MFW_NUMITEMS; i++) - if (wiz->m_Info[i]) - wiz->m_Info[i]->DeRef(); } break; case LC_PIECE_ARRAY: @@ -7502,6 +7506,8 @@ void Project::OnLeftButtonDown(View* view, int x, int y, bool bControl, bool bSh SetAction(LC_ACTION_ROTATE_VIEW); m_RestoreAction = true; } + else + m_RestoreAction = false; switch (m_nCurAction) {