Fixed decimal point when saving text files.

This commit is contained in:
leo 2012-02-08 22:48:51 +00:00
parent 9bf9fc45b5
commit 5ffe86ae21
4 changed files with 62 additions and 32 deletions

View file

@ -101,8 +101,6 @@ protected:
int m_nMovedCount; // number of moved pieces int m_nMovedCount; // number of moved pieces
char* m_pMovedReference; // moved pieces list char* m_pMovedReference; // moved pieces list
int m_nPieceCount; // number of pieces
PieceInfo* m_pPieceIdx; // pieces array
int m_nTextureCount; // number of textures int m_nTextureCount; // number of textures
Texture* m_pTextures; // textures array Texture* m_pTextures; // textures array

View file

@ -862,6 +862,27 @@ MinifigWizard::MinifigWizard (GLWindow *share)
Sys_MessageBox ("Unknown Minifig Preferences."); 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 () MinifigWizard::~MinifigWizard ()
{ {
char *ptr, buf[32]; char *ptr, buf[32];
@ -905,6 +926,10 @@ MinifigWizard::~MinifigWizard ()
free (m_MinifigNames); free (m_MinifigNames);
free (m_MinifigTemplates); free (m_MinifigTemplates);
for (i = 0; i < LC_MFW_NUMITEMS; i++)
if (m_Info[i])
m_Info[i]->DeRef();
} }
void MinifigWizard::ParseSettings(File& Settings) void MinifigWizard::ParseSettings(File& Settings)

View file

@ -30,7 +30,7 @@ enum LC_MFW_TYPES
struct lcMinifigPieceInfo struct lcMinifigPieceInfo
{ {
char Description[80]; char Description[128];
PieceInfo* Info; PieceInfo* Info;
Matrix44 Offset; Matrix44 Offset;
}; };
@ -42,6 +42,7 @@ public:
~MinifigWizard (); ~MinifigWizard ();
void OnDraw (); void OnDraw ();
void OnInitialUpdate();
void Calculate(); void Calculate();
int GetSelectionIndex(int Type) const; int GetSelectionIndex(int Type) const;

View file

@ -1276,6 +1276,8 @@ bool Project::DoSave(char* lpszPathName, bool bReplace)
strcat(buf, "\r\n"); strcat(buf, "\r\n");
file.Write(buf, strlen(buf)); file.Write(buf, strlen(buf));
const char* OldLocale = setlocale(LC_NUMERIC, "C");
for (i = 1; i <= steps; i++) for (i = 1; i <= steps; i++)
{ {
for (pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext) 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 STEP\r\n", 8);
} }
file.Write("0\r\n", 3); file.Write("0\r\n", 3);
setlocale(LC_NUMERIC, OldLocale);
} }
else else
FileSave(&file, false); // save me FileSave(&file, false); // save me
file.Close(); file.Close();
SetModifiedFlag(false); // back to unmodified SetModifiedFlag(false); // back to unmodified
@ -3955,6 +3960,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
break; break;
} }
const char* OldLocale = setlocale(LC_NUMERIC, "C");
fputs("// Stuff that doesn't need to be changed\n\n", f); fputs("// Stuff that doesn't need to be changed\n\n", f);
if (strlen(opts.libpath)) if (strlen(opts.libpath))
@ -4147,6 +4153,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
if (!f) if (!f)
{ {
SystemDoMessageBox("Could not open file for writing.", LC_MB_OK|LC_MB_ICONERROR); SystemDoMessageBox("Could not open file for writing.", LC_MB_OK|LC_MB_ICONERROR);
setlocale(LC_NUMERIC, OldLocale);
break; break;
} }
@ -4212,6 +4219,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
fclose (f); fclose (f);
free (conv); free (conv);
free (flags); free (flags);
setlocale(LC_NUMERIC, OldLocale);
if (opts.render) if (opts.render)
{ {
@ -4847,36 +4855,36 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
case LC_PIECE_MINIFIG: case LC_PIECE_MINIFIG:
{ {
MinifigWizard *wiz = new MinifigWizard (m_ViewList[0]); MinifigWizard Wizard(m_ActiveView);
int i; int i;
if (SystemDoDialog (LC_DLG_MINIFIG, wiz)) if (SystemDoDialog(LC_DLG_MINIFIG, &Wizard))
{ {
SelectAndFocusNone(false); SelectAndFocusNone(false);
for (i = 0; i < LC_MFW_NUMITEMS; i++) for (i = 0; i < LC_MFW_NUMITEMS; i++)
{ {
if (wiz->m_Info[i] == NULL) if (Wizard.m_Info[i] == NULL)
continue; continue;
Matrix mat; Matrix mat;
Piece* pPiece = new Piece(wiz->m_Info[i]); Piece* pPiece = new Piece(Wizard.m_Info[i]);
Vector4& Position = wiz->m_Matrices[i][3]; Vector4& Position = Wizard.m_Matrices[i][3];
Vector4 Rotation = wiz->m_Matrices[i].ToAxisAngle(); Vector4 Rotation = Wizard.m_Matrices[i].ToAxisAngle();
Rotation[3] *= LC_RTOD; Rotation[3] *= LC_RTOD;
pPiece->Initialize(Position[0], Position[1], Position[2], m_nCurStep, m_nCurFrame, wiz->m_Colors[i]); pPiece->Initialize(Position[0], Position[1], Position[2], m_nCurStep, m_nCurFrame, Wizard.m_Colors[i]);
pPiece->CreateName(m_pPieces); pPiece->CreateName(m_pPieces);
AddPiece(pPiece); AddPiece(pPiece);
pPiece->Select(true, false, false); pPiece->Select(true, false, false);
pPiece->ChangeKey(1, false, false, Rotation, LC_PK_ROTATION); pPiece->ChangeKey(1, false, false, Rotation, LC_PK_ROTATION);
pPiece->ChangeKey(1, true, 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->UpdatePosition(m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation);
pPiece->CalculateConnections(m_pConnections, m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, false, true); 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 }; float bs[6] = { 10000, 10000, 10000, -10000, -10000, -10000 };
int max = 0; 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[1] = (bs[1]+bs[4])/2;
pGroup->m_fCenter[2] = (bs[2]+bs[5])/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(); UpdateSelection();
UpdateAllViews(); UpdateAllViews();
SetModifiedFlag(true); SetModifiedFlag(true);
CheckPoint("Minifig"); CheckPoint("Minifig");
} }
for (i = 0; i < LC_MFW_NUMITEMS; i++)
if (wiz->m_Info[i])
wiz->m_Info[i]->DeRef();
} break; } break;
case LC_PIECE_ARRAY: 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); SetAction(LC_ACTION_ROTATE_VIEW);
m_RestoreAction = true; m_RestoreAction = true;
} }
else
m_RestoreAction = false;
switch (m_nCurAction) switch (m_nCurAction)
{ {