summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/globals.cpp1
-rw-r--r--common/globals.h3
-rw-r--r--common/lc_application.cpp407
-rw-r--r--common/lc_application.h51
-rwxr-xr-xcommon/library.cpp3
-rw-r--r--common/minifig.cpp13
-rwxr-xr-xcommon/object.cpp3
-rw-r--r--common/piece.cpp25
-rw-r--r--common/pieceinf.cpp5
-rw-r--r--common/preview.cpp7
-rw-r--r--common/project.cpp358
-rw-r--r--common/project.h10
-rw-r--r--common/str.h2
-rw-r--r--common/texfont.cpp3
-rw-r--r--common/texture.cpp3
-rw-r--r--common/typedefs.h2
16 files changed, 560 insertions, 336 deletions
diff --git a/common/globals.cpp b/common/globals.cpp
index f0e885c..8a186ef 100644
--- a/common/globals.cpp
+++ b/common/globals.cpp
@@ -5,7 +5,6 @@
#include <stdlib.h>
#include "globals.h"
-Project* project;
Messenger* messenger;
MainWnd* main_window;
diff --git a/common/globals.h b/common/globals.h
index 312251c..6f6daa1 100644
--- a/common/globals.h
+++ b/common/globals.h
@@ -5,9 +5,6 @@
#include "typedefs.h"
#include "console.h"
-class Project;
-extern Project* project;
-
class Messenger;
extern Messenger* messenger;
diff --git a/common/lc_application.cpp b/common/lc_application.cpp
new file mode 100644
index 0000000..13ef637
--- /dev/null
+++ b/common/lc_application.cpp
@@ -0,0 +1,407 @@
+#include <stdio.h>
+#include "lc_application.h"
+#include "library.h"
+#include "system.h"
+#include "console.h"
+#include "config.h"
+#include "opengl.h"
+#include "project.h"
+#include "image.h"
+
+// ----------------------------------------------------------------------------
+// Global functions.
+
+lcApplication* g_App;
+
+PiecesLibrary* lcGetPiecesLibrary()
+{
+ LC_ASSERT(g_App, "g_App not initialized.");
+ return g_App->GetPiecesLibrary();
+}
+
+Project* lcGetActiveProject()
+{
+ LC_ASSERT(g_App, "g_App not initialized.");
+ return g_App->GetActiveProject();
+}
+
+// ----------------------------------------------------------------------------
+// lcApplication class.
+
+lcApplication::lcApplication()
+{
+ m_ActiveProject = NULL;
+ m_Library = NULL;
+}
+
+lcApplication::~lcApplication()
+{
+}
+
+void lcApplication::AddProject(Project* project)
+{
+ m_Projects.Add(project);
+
+ if (m_ActiveProject == NULL)
+ m_ActiveProject = project;
+}
+
+bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* SysLibPath)
+{
+ // Create an empty library.
+ if (m_Library == NULL)
+ m_Library = new PiecesLibrary();
+ else
+ m_Library->Unload();
+
+ // Check if the user specified a library path in the command line.
+ if (LibPath != NULL)
+ if (m_Library->Load(LibPath))
+ return true;
+
+ // Check for the LEOCAD_LIB environment variable.
+ char* EnvPath = getenv("LEOCAD_LIB");
+
+ if (EnvPath != NULL)
+ if (m_Library->Load(EnvPath))
+ return true;
+
+ // Try the executable install path last.
+ if (SysLibPath != NULL)
+ if (m_Library->Load(SysLibPath))
+ return true;
+
+#ifdef LC_WINDOWS
+ SystemDoMessageBox("Cannot load pieces library.\n"
+ "Make sure that you have the PIECES.IDX file in the same "
+ "folder where you installed the program.", LC_MB_OK|LC_MB_ICONERROR);
+#else
+ printf("Error: Cannot load pieces library.\n");
+#endif
+
+ return false;
+}
+
+void lcApplication::ParseIntegerArgument(int* CurArg, int argc, char* argv[], int* Value)
+{
+ if (argc > (*CurArg + 1))
+ {
+ (*CurArg)++;
+ int val;
+
+ if ((sscanf(argv[(*CurArg)], "%d", &val) == 1) && (val > 0))
+ *Value = val;
+ else
+ console.PrintWarning("Invalid value specified for the %s argument.", argv[(*CurArg) - 1]);
+ }
+ else
+ {
+ console.PrintWarning("Not enough parameters for the %s argument.", argv[(*CurArg) - 1]);
+ }
+}
+
+void lcApplication::ParseStringArgument(int* CurArg, int argc, char* argv[], char** Value)
+{
+ if (argc > (*CurArg + 1))
+ {
+ (*CurArg)++;
+ *Value = argv[(*CurArg)];
+ }
+ else
+ {
+ console.PrintWarning("No path specified after the %s argument.", argv[(*CurArg) - 1]);
+ }
+}
+
+bool lcApplication::Initialize(int argc, char* argv[], const char* SysLibPath)
+{
+ // System setup parameters.
+ char* LibPath = NULL;
+ char* GLPath = NULL;
+
+ // Image output options.
+ bool SaveImage = false;
+ bool ImageAnimation = false;
+ bool ImageInstructions = false;
+ bool ImageHighlight = false;
+ int ImageWidth = Sys_ProfileLoadInt("Default", "Image Width", 640);
+ int ImageHeight = Sys_ProfileLoadInt("Default", "Image Height", 480);
+ int ImageStart = 0;
+ int ImageEnd = 0;
+ char* ImageName = NULL;
+
+ // File to open.
+ char* ProjectName = NULL;
+
+ // Parse the command line arguments.
+ for (int i = 1; i < argc; i++)
+ {
+ char* Param = argv[i];
+
+ if (Param[0] == '-')
+ {
+ if (strcmp(Param, "--libgl") == 0)
+ {
+ ParseStringArgument(&i, argc, argv, &GLPath);
+ }
+ else if ((strcmp(Param, "-l") == 0) || (strcmp(Param, "--libpath") == 0))
+ {
+ ParseStringArgument(&i, argc, argv, &LibPath);
+ }
+ else if ((strcmp(Param, "-i") == 0) || (strcmp(Param, "--image") == 0))
+ {
+ SaveImage = true;
+
+ if ((argc > (i+1)) && (argv[i+1][0] != '-'))
+ {
+ i++;
+ ImageName = argv[i];
+ }
+ }
+ else if ((strcmp(Param, "-w") == 0) || (strcmp(Param, "--width") == 0))
+ {
+ ParseIntegerArgument(&i, argc, argv, &ImageWidth);
+ }
+ else if ((strcmp(Param, "-h") == 0) || (strcmp(Param, "--height") == 0))
+ {
+ ParseIntegerArgument(&i, argc, argv, &ImageHeight);
+ }
+ else if ((strcmp(Param, "-f") == 0) || (strcmp(Param, "--from") == 0))
+ {
+ ParseIntegerArgument(&i, argc, argv, &ImageStart);
+ }
+ else if ((strcmp(Param, "-t") == 0) || (strcmp(Param, "--to") == 0))
+ {
+ ParseIntegerArgument(&i, argc, argv, &ImageEnd);
+ }
+ else if (strcmp(Param, "--animation") == 0)
+ ImageAnimation = true;
+ else if (strcmp(Param, "--instructions") == 0)
+ ImageInstructions = true;
+ else if (strcmp(Param, "--highlight") == 0)
+ ImageHighlight = true;
+ else if ((strcmp(Param, "-v") == 0) || (strcmp(Param, "--version") == 0))
+ {
+ printf("LeoCAD version " LC_VERSION_TEXT LC_VERSION_TAG " for "LC_VERSION_OSNAME"\n");
+ printf("Copyright (c) 1996-2006, BT Software\n");
+ printf("Compiled "__DATE__"\n");
+
+#ifdef LC_HAVE_JPEGLIB
+ printf("With JPEG support\n");
+#else
+ printf("Without JPEG support\n");
+#endif
+
+#ifdef LC_HAVE_PNGLIB
+ printf("With PNG support\n");
+#else
+ printf("Without PNG support\n");
+#endif
+
+ return false;
+ }
+ else if ((strcmp(Param, "-?") == 0) || (strcmp(Param, "--help") == 0))
+ {
+ printf("Usage: leocad [options] [file]\n");
+ printf(" [options] can be:\n");
+ printf(" --libgl <path>: Searches for OpenGL libraries in path.\n");
+ printf(" --libpath <path>: Loads the Pieces library from path.\n");
+ printf(" -i, --image <outfile.ext>: Saves a picture in the format specified by ext.\n");
+ printf(" -w, --width <width>: Sets the picture width.\n");
+ printf(" -h, --height <height>: Sets the picture height.\n");
+ printf(" -f, --from <time>: Sets the first frame or step to save pictures.\n");
+ printf(" -t, --to <time>: Sets the last frame or step to save pictures.\n");
+ printf(" --animation: Saves animations frames.\n");
+ printf(" --instructions: Saves instructions steps.\n");
+ printf(" --highlight: Highlight pieces in the steps they appear.\n");
+ printf(" \n");
+ }
+ else
+ console.PrintWarning("Unknown parameter: %s\n", Param);
+ }
+ else
+ {
+ ProjectName = Param;
+ }
+ }
+
+ // Initialize other systems.
+ if (!GL_Initialize(GLPath))
+ return false;
+
+ if (!LoadPiecesLibrary(LibPath, SysLibPath))
+ return false;
+
+ SystemInit();
+
+ // Create a new project.
+ Project* project = new Project();
+ AddProject(project);
+
+ // Load project.
+ if (ProjectName && project->OpenProject(ProjectName))
+ {
+ if (!SaveImage)
+ return true;
+
+ // Check if there's a file name and it has an extension.
+ bool NeedExt = true;
+ String FileName;
+
+ if (!ImageName)
+ {
+ FileName = ProjectName;
+
+ int i = FileName.ReverseFind('.');
+ if (i != -1)
+ FileName[i] = 0;
+ }
+ else
+ {
+ FileName = ImageName;
+
+ int i = FileName.ReverseFind('.');
+ String Ext;
+
+ if (i != -1)
+ {
+ Ext = FileName.Right(FileName.GetLength() - i);
+ Ext.MakeLower();
+ }
+
+ if ((Ext == "bmp") || (Ext == "gif"))
+ NeedExt = false;
+#ifdef LC_HAVE_JPEGLIB
+ else if ((Ext == "jpg") || (Ext == "jpeg"))
+ NeedExt = false;
+#endif
+#ifdef LC_HAVE_PNGLIB
+ else if (Ext == "png")
+ NeedExt = false;
+#endif
+ }
+
+ // Setup default options.
+ LC_IMAGE_OPTS ImageOptions;
+ unsigned long image = Sys_ProfileLoadInt ("Default", "Image Options", 1|LC_IMAGE_TRANSPARENT);
+ ImageOptions.quality = Sys_ProfileLoadInt ("Default", "JPEG Quality", 70);
+ ImageOptions.interlaced = (image & LC_IMAGE_PROGRESSIVE) != 0;
+ ImageOptions.transparent = (image & LC_IMAGE_TRANSPARENT) != 0;
+ ImageOptions.truecolor = (image & LC_IMAGE_HIGHCOLOR) != 0;
+ ImageOptions.format = image & ~(LC_IMAGE_MASK);
+ ImageOptions.background[0] = (unsigned char)(project->GetBackgroundColor()[0]*255);
+ ImageOptions.background[1] = (unsigned char)(project->GetBackgroundColor()[1]*255);
+ ImageOptions.background[2] = (unsigned char)(project->GetBackgroundColor()[2]*255);
+
+ // Append file extension if needed.
+ if (NeedExt)
+ {
+ switch (ImageOptions.format)
+ {
+ default:
+ case LC_IMAGE_BMP:
+ FileName += ".bmp";
+ break;
+ case LC_IMAGE_GIF:
+ FileName += ".gif";
+ break;
+ case LC_IMAGE_JPG:
+ FileName += ".jpg";
+ break;
+ case LC_IMAGE_PNG:
+ FileName += ".png";
+ break;
+ }
+ }
+
+ if (ImageInstructions)
+ project->SetAnimation(false);
+ else if (ImageAnimation)
+ project->SetAnimation(true);
+
+ if (ImageEnd < ImageStart)
+ ImageEnd = ImageStart;
+ else if (ImageStart > ImageEnd)
+ ImageStart = ImageEnd;
+
+ if ((ImageStart == 0) && (ImageEnd == 0))
+ {
+ ImageStart = ImageEnd = project->GetCurrentTime();
+ }
+ else if ((ImageStart == 0) && (ImageEnd != 0))
+ {
+ ImageStart = ImageEnd;
+ }
+ else if ((ImageStart != 0) && (ImageEnd == 0))
+ {
+ ImageEnd = ImageStart;
+ }
+
+ if (project->IsAnimation())
+ {
+ if (ImageStart > project->GetTotalFrames())
+ ImageStart = project->GetTotalFrames();
+
+ if (ImageEnd > project->GetTotalFrames())
+ ImageEnd = project->GetTotalFrames();
+ }
+ else
+ {
+ if (ImageStart > 255)
+ ImageStart = 255;
+
+ if (ImageEnd > 255)
+ ImageEnd = 255;
+ }
+
+ Image* images = new Image[ImageEnd - ImageStart + 1];
+ project->CreateImages(images, ImageWidth, ImageHeight, ImageStart, ImageEnd, ImageHighlight);
+
+ for (i = 0; i <= ImageEnd - ImageStart; i++)
+ {
+ char idx[256];
+ String Frame;
+
+ if (ImageStart != ImageEnd)
+ {
+ sprintf(idx, "%02d", i+1);
+ int Ext = FileName.ReverseFind('.');
+
+ Frame = FileName.Left(Ext) + idx + FileName.Right(FileName.GetLength() - Ext);
+ }
+ else
+ Frame = FileName;
+
+ images[i].FileSave(Frame, &ImageOptions);
+ }
+
+ delete []images;
+
+ return false;
+ }
+ else
+ {
+ if (SaveImage)
+ return false;
+ else
+ project->OnNewDocument();
+ }
+
+ return true;
+}
+
+void lcApplication::Shutdown()
+{
+ for (int i = 0; i < m_Projects.GetSize(); i++)
+ {
+ Project* project = m_Projects[i];
+
+ project->HandleNotify(LC_ACTIVATE, 0);
+ delete project;
+ }
+
+ delete m_Library;
+ m_Library = NULL;
+
+ GL_Shutdown();
+}
diff --git a/common/lc_application.h b/common/lc_application.h
new file mode 100644
index 0000000..0336f10
--- /dev/null
+++ b/common/lc_application.h
@@ -0,0 +1,51 @@
+#ifndef _LC_APPLICATION_H_
+#define _LC_APPLICATION_H_
+
+#include "array.h"
+
+class Project;
+class PiecesLibrary;
+
+class lcApplication
+{
+public:
+ lcApplication();
+ ~lcApplication();
+
+ bool Initialize(int argc, char *argv[], const char* SysLibPath);
+ void Shutdown();
+
+ // Pieces library.
+ bool LoadPiecesLibrary(const char* LibPath, const char* SysLibPath);
+ PiecesLibrary* GetPiecesLibrary() const
+ {
+ return m_Library;
+ }
+
+ // Projects.
+ void AddProject(Project* project);
+
+ Project* GetActiveProject() const
+ {
+ return m_ActiveProject;
+ }
+
+ void SetActiveProject(Project* project)
+ {
+ m_ActiveProject = project;
+ }
+
+protected:
+ void ParseIntegerArgument(int* CurArg, int argc, char* argv[], int* Value);
+ void ParseStringArgument(int* CurArg, int argc, char* argv[], char** Value);
+
+ Project* m_ActiveProject;
+ PtrArray<Project> m_Projects;
+ PiecesLibrary* m_Library;
+};
+
+extern lcApplication* g_App;
+PiecesLibrary* lcGetPiecesLibrary();
+Project* lcGetActiveProject();
+
+#endif // _LC_APPLICATION_H_
diff --git a/common/library.cpp b/common/library.cpp
index c1e495c..04939dd 100755
--- a/common/library.cpp
+++ b/common/library.cpp
@@ -11,6 +11,7 @@
#include "image.h"
#include "system.h"
#include "console.h"
+#include "lc_application.h"
// =============================================================================
// PiecesLibrary class
@@ -2266,7 +2267,7 @@ bool SaveLDrawPiece(LC_LDRAW_PIECE* piece)
unsigned long i, j, cs, binoff = 0, delta;
void* membuf;
short scale, sb[6];
- PiecesLibrary *pLib = project->GetPiecesLibrary ();
+ PiecesLibrary *pLib = lcGetPiecesLibrary();
strcpy(file1, pLib->GetLibraryPath());
strcat(file1, "pieces-b.old");
diff --git a/common/minifig.cpp b/common/minifig.cpp
index a8e7d33..9098e49 100644
--- a/common/minifig.cpp
+++ b/common/minifig.cpp
@@ -13,6 +13,7 @@
#include "system.h"
#include "matrix.h"
#include "library.h"
+#include "lc_application.h"
// =============================================================================
// Static variables
@@ -442,7 +443,7 @@ MinifigWizard::MinifigWizard (GLWindow *share)
m_Colors[i] = colors[i];
m_Angles[i] = 0;
- m_Info[i] = project->GetPiecesLibrary ()->FindPieceInfo (pieces[i]);
+ m_Info[i] = lcGetPiecesLibrary()->FindPieceInfo(pieces[i]);
if (m_Info[i] != NULL)
m_Info[i]->AddRef();
}
@@ -451,7 +452,7 @@ MinifigWizard::MinifigWizard (GLWindow *share)
m_MinifigNames = NULL;
m_MinifigTemplates = NULL;
- i = Sys_ProfileLoadInt ("MinifigWizard", "Version", 1);
+ i = Sys_ProfileLoadInt("MinifigWizard", "Version", 1);
if (i == 1)
{
char *ptr, buf[32];
@@ -552,7 +553,7 @@ void MinifigWizard::OnDraw ()
glEnable (GL_DEPTH_TEST);
glDepthFunc (GL_LEQUAL);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- float *bg = project->GetBackgroundColor();
+ float *bg = lcGetActiveProject()->GetBackgroundColor();
glClearColor (bg[0], bg[1], bg[2], bg[3]);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable (GL_DITHER);
@@ -888,7 +889,7 @@ void MinifigWizard::GetDescriptions (int type, char ***names, int *count)
{
PieceInfo* piece_info;
- piece_info = project->GetPiecesLibrary ()->FindPieceInfo (mfw_pieceinfo[i].name);
+ piece_info = lcGetPiecesLibrary()->FindPieceInfo(mfw_pieceinfo[i].name);
if (piece_info == NULL)
continue;
@@ -971,7 +972,7 @@ void MinifigWizard::ChangePiece (int type, const char *desc)
{
if (strcmp(desc, mfw_pieceinfo[j].description) == 0)
{
- piece_info = project->GetPiecesLibrary()->FindPieceInfo(mfw_pieceinfo[j].name);
+ piece_info = lcGetPiecesLibrary()->FindPieceInfo(mfw_pieceinfo[j].name);
if (piece_info == NULL)
continue;
@@ -1083,7 +1084,7 @@ bool MinifigWizard::LoadMinifig (const char* name)
endptr = strchr (ptr, ' ');
*endptr = '\0';
- m_Info[j] = project->GetPiecesLibrary ()->FindPieceInfo (ptr);
+ m_Info[j] = lcGetPiecesLibrary()->FindPieceInfo (ptr);
*endptr = ' ';
ptr = endptr;
diff --git a/common/object.cpp b/common/object.cpp
index cdcb107..489ad12 100755
--- a/common/object.cpp
+++ b/common/object.cpp
@@ -10,6 +10,7 @@
#include "matrix.h"
#include "vector.h"
#include "file.h"
+#include "lc_application.h"
#define LC_KEY_SAVE_VERSION 1 // LeoCAD 0.73
@@ -347,7 +348,7 @@ void Object::InsertTime (unsigned short start, bool animation, unsigned short ti
if (animation)
{
node = m_pAnimationKeys;
- last = project->GetTotalFrames ();
+ last = lcGetActiveProject()->GetTotalFrames ();
}
else
{
diff --git a/common/piece.cpp b/common/piece.cpp
index 2a11bd5..684bcd5 100644
--- a/common/piece.cpp
+++ b/common/piece.cpp
@@ -13,6 +13,7 @@
#include "group.h"
#include "project.h"
#include "algebra.h"
+#include "lc_application.h"
#define LC_PIECE_SAVE_VERSION 9 // LeoCAD 0.73
@@ -420,23 +421,23 @@ void Piece::InsertTime (unsigned short start, bool animation, unsigned short tim
if (animation)
{
if (m_nFrameShow >= start)
- m_nFrameShow = min (m_nFrameShow + time, project->GetTotalFrames ());
+ m_nFrameShow = min(m_nFrameShow + time, lcGetActiveProject()->GetTotalFrames());
if (m_nFrameHide >= start)
- m_nFrameHide = min (m_nFrameHide + time, project->GetTotalFrames ());
+ m_nFrameHide = min(m_nFrameHide + time, lcGetActiveProject()->GetTotalFrames());
- if (m_nFrameShow > project->GetCurrentTime ())
+ if (m_nFrameShow > lcGetActiveProject()->GetCurrentTime())
Select (false, false, false);
}
else
{
if (m_nStepShow >= start)
- m_nStepShow = min (m_nStepShow + time, 255);
+ m_nStepShow = min(m_nStepShow + time, 255);
if (m_nStepHide >= start)
- m_nStepHide = min (m_nStepHide + time, 255);
+ m_nStepHide = min(m_nStepHide + time, 255);
- if (m_nStepShow > project->GetCurrentTime ())
+ if (m_nStepShow > lcGetActiveProject()->GetCurrentTime ())
Select (false, false, false);
}
@@ -448,14 +449,14 @@ void Piece::RemoveTime (unsigned short start, bool animation, unsigned short tim
if (animation)
{
if (m_nFrameShow >= start)
- m_nFrameShow = max (m_nFrameShow - time, 1);
+ m_nFrameShow = max(m_nFrameShow - time, 1);
- if (m_nFrameHide == project->GetTotalFrames ())
- m_nFrameHide = project->GetTotalFrames ();
+ if (m_nFrameHide == lcGetActiveProject()->GetTotalFrames())
+ m_nFrameHide = lcGetActiveProject()->GetTotalFrames();
else
- m_nFrameHide = max (m_nFrameHide - time, 1);
+ m_nFrameHide = max(m_nFrameHide - time, 1);
- if (m_nFrameHide < project->GetCurrentTime ())
+ if (m_nFrameHide < lcGetActiveProject()->GetCurrentTime())
Select (false, false, false);
}
else
@@ -466,7 +467,7 @@ void Piece::RemoveTime (unsigned short start, bool animation, unsigned short tim
if (m_nStepHide != 255)
m_nStepHide = max (m_nStepHide - time, 1);
- if (m_nStepHide < project->GetCurrentTime ())
+ if (m_nStepHide < lcGetActiveProject()->GetCurrentTime())
Select (false, false, false);
}
diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp
index ffb1a76..9a9d30a 100644
--- a/common/pieceinf.cpp
+++ b/common/pieceinf.cpp
@@ -15,6 +15,7 @@
#include "defines.h"
#include "config.h"
#include "library.h"
+#include "lc_application.h"
#define SIDES 16
static float sintbl[SIDES];
@@ -320,7 +321,7 @@ void PieceInfo::LoadInformation()
glEndList ();
// Open pieces.bin and buffer the information we need.
- strcpy (filename, project->GetPiecesLibrary ()->GetLibraryPath());
+ strcpy (filename, lcGetPiecesLibrary()->GetLibraryPath());
strcat (filename, "pieces.bin");
if (!bin.Open (filename, "rb"))
return;
@@ -381,7 +382,7 @@ void PieceInfo::LoadInformation()
bytes++;
strcpy(name, (char*)bytes);
- tex->texture = project->GetPiecesLibrary()->FindTexture(name);
+ tex->texture = lcGetPiecesLibrary()->FindTexture(name);
shorts = (lcint16*)(bytes + 8);
for (i = 0; i < 4; i++)
diff --git a/common/preview.cpp b/common/preview.cpp
index d792849..82d16f6 100644
--- a/common/preview.cpp
+++ b/common/preview.cpp
@@ -7,6 +7,7 @@
#include "project.h"
#include "pieceinf.h"
#include "system.h"
+#include "lc_application.h"
PiecePreview::PiecePreview(GLWindow *share)
: GLWindow(share)
@@ -76,11 +77,11 @@ void PiecePreview::OnDraw()
glLoadMatrixf(WorldToView);
}
- float pos[4] = { 0, 0, 10, 0 }, *bg = project->GetBackgroundColor ();
+ float pos[4] = { 0, 0, 10, 0 }, *bg = lcGetActiveProject()->GetBackgroundColor ();
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glClearColor(bg[0], bg[1], bg[2], bg[3]);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- m_PieceInfo->RenderPiece(project->GetCurrentColor ());
+ m_PieceInfo->RenderPiece(lcGetActiveProject()->GetCurrentColor());
glFinish();
SwapBuffers();
@@ -98,7 +99,7 @@ void PiecePreview::SetCurrentPiece(PieceInfo *pInfo)
if (m_PieceInfo != NULL)
{
m_PieceInfo->AddRef();
- project->SetCurrentPiece(m_PieceInfo);
+ lcGetActiveProject()->SetCurrentPiece(m_PieceInfo);
Redraw();
}
}
diff --git a/common/project.cpp b/common/project.cpp
index 23c487e..1ddf706 100644
--- a/common/project.cpp
+++ b/common/project.cpp
@@ -31,6 +31,7 @@
#include "texfont.h"
#include "algebra.h"
#include "debug.h"
+#include "lc_application.h"
// FIXME: temporary function, replace the code !!!
void SystemUpdateFocus (void* p)
@@ -119,7 +120,6 @@ Project::Project()
for (i = 0; i < 10; i++)
m_pClipboard[i] = NULL;
- m_pLibrary = new PiecesLibrary ();
m_pScreenFont = new TexFont();
}
@@ -143,291 +143,53 @@ Project::~Project()
delete m_pTerrain;
delete m_pBackground;
delete m_pScreenFont;
- delete m_pLibrary;
}
/////////////////////////////////////////////////////////////////////////////
// Project attributes, general services
-// The main window should be created before calling this
-bool Project::Initialize(int argc, char *argv[], char* binpath, char* libpath)
+void Project::UpdateInterface()
{
- char *env_path;
- bool loaded = false;
-
- // check if there's an environment variable for the piece library
- env_path = getenv ("LEOCAD_LIB");
- if (env_path != NULL)
- libpath = env_path;
-
- m_strPathName[0] = 0;
-
- LC_IMAGE_OPTS imopts;
- char picture[LC_MAXPATH];
- bool save_image = false;
- picture[0] = 0;
-
- unsigned long image = Sys_ProfileLoadInt ("Default", "Image Options", 1|LC_IMAGE_TRANSPARENT);
- int width = Sys_ProfileLoadInt ("Default", "Image Width", 640);
- int height = Sys_ProfileLoadInt ("Default", "Image Height", 480);
-// int width = Sys_ProfileLoadInt ("Default", "Image Width", GetSystemMetrics(SM_CXSCREEN));
-// int height = Sys_ProfileLoadInt ("Default", "Image Height", GetSystemMetrics(SM_CYSCREEN));
- unsigned short from = 0, to = 0;
- int i, animation = -1;
- bool highlight = false;
- imopts.quality = Sys_ProfileLoadInt ("Default", "JPEG Quality", 70);
- imopts.interlaced = (image & LC_IMAGE_PROGRESSIVE) != 0;
- imopts.transparent = (image & LC_IMAGE_TRANSPARENT) != 0;
- imopts.truecolor = (image & LC_IMAGE_HIGHCOLOR) != 0;
- imopts.format = (unsigned char)(image & ~(LC_IMAGE_MASK));
-
- for (i = 1; i < argc; i++)
- {
- char* param = argv[i];
-
- if (param[0] == '-')
- {
- if (((strcmp (param, "-l") == 0) || (strcmp (param, "--libpath") == 0)) && ((i+1) < argc))
- {
- i++;
- libpath = argv[i];
- }
- else if ((strcmp (param, "-i") == 0) || (strcmp (param, "--image") == 0))
- {
- save_image = true;
-
- if (((i+1) != argc) && (argv[i+1][0] != '-'))
- {
- i++;
- strcpy (picture, argv[i]);
- }
- }
- else if (((strcmp (param, "-w") == 0) || (strcmp (param, "--width") == 0)) && ((i+1) < argc))
- {
- int w;
- i++;
- if (sscanf(argv[i], "%d", &w) == 1)
- width = w;
- }
- else if (((strcmp (param, "-h") == 0) || (strcmp (param, "--height") == 0)) && ((i+1) < argc))
- {
- int h;
- i++;
- if (sscanf(argv[i], "%d", &h) == 1)
- height = h;
- }
- else if (((strcmp (param, "-f") == 0) || (strcmp (param, "--from") == 0)) && ((i+1) < argc))
- {
- int f;
- i++;
- if (sscanf(argv[i], "%d", &f) == 1)
- from = f;
- }
- else if (((strcmp (param, "-t") == 0) || (strcmp (param, "--to") == 0)) && ((i+1) < argc))
- {
- int t;
- i++;
- if (sscanf(argv[i], "%d", &t) == 1)
- to = t;
- }
- else if (strcmp (param, "--animation") == 0)
- animation = 1;
- else if (strcmp (param, "--instructions") == 0)
- animation = 0;
- else if (strcmp (param, "--highlight") == 0)
- highlight = true;
- else if ((strcmp (param, "-v") == 0) || (strcmp (param, "--version") == 0))
- {
- printf ("LeoCAD version " LC_VERSION_TEXT LC_VERSION_TAG " for "LC_VERSION_OSNAME"\n");
- printf ("Copyright (c) 1996-2003, BT Software\n");
- printf ("Compiled "__DATE__"\n");
-
-#ifdef LC_HAVE_JPEGLIB
- printf ("With JPEG support\n");
-#else
- printf ("Without JPEG support\n");
-#endif
-
-#ifdef LC_HAVE_PNGLIB
- printf ("With PNG support\n");
-#else
- printf ("Without PNG support\n");
-#endif
-
- return false;
- }
- else if ((strcmp (param, "-h") == 0) || (strcmp (param, "--help") == 0))
- {
- }
- else
- printf ("Unknown parameter: %s\n", param);
- }
- else
- {
- strcpy (m_strPathName, param);
-/*
- if (m_strFileName.IsEmpty())
- m_strFileName = pszParam;
- else if (m_nShellCommand == FilePrintTo && m_strPrinterName.IsEmpty())
- m_strPrinterName = pszParam;
- else if (m_nShellCommand == FilePrintTo && m_strDriverName.IsEmpty())
- m_strDriverName = pszParam;
- else if (m_nShellCommand == FilePrintTo && m_strPortName.IsEmpty())
- m_strPortName = pszParam;
-*/
- }
- }
-
- // if the user specified a library, try to load it first
- if (libpath != NULL)
- loaded = m_pLibrary->Load (libpath);
-
- // if we couldn't find a library, try the executable path
- if (!loaded)
- loaded = m_pLibrary->Load (binpath);
-
- if (!loaded)
- {
-#ifdef LC_WINDOWS
- // let's hope this message helps the users
- SystemDoMessageBox("Cannot load piece library.\n"
- "Make sure that you have the PIECES.IDX file in the same "
- "folder where you installed the program.", LC_MB_OK|LC_MB_ICONERROR);
-#else
- printf("Cannot load piece library !\n");
-#endif
- return false;
- }
-
- SystemInit();
-
- if (strlen(m_strPathName) && OnOpenDocument(m_strPathName))
- {
- SetPathName(m_strPathName, true);
-
- if (save_image == true)
- {
- bool need_ext = false;
-
- if (picture[0] == 0)
- {
- strcpy (picture, m_strPathName);
- char *p = strrchr (picture, '.');
- if (p != NULL)
- *p = 0;
- need_ext = true;
- }
- else
- {
- char ext[5];
- char *p = strrchr(picture, '.');
- if (p != NULL)
- strcpy(ext, p+1);
- strlwr(ext);
-
- if ((strcmp(ext, "bmp") != 0) && (strcmp(ext, "gif") != 0) &&
- (strcmp(ext, "jpg") != 0) && (strcmp(ext, "jpeg") != 0) &&
- (strcmp(ext, "png") != 0))
- need_ext = true;
- }
-
- if (need_ext)
- switch (imopts.format)
- {
- case LC_IMAGE_BMP: strcat(picture, ".bmp"); break;
- case LC_IMAGE_GIF: strcat(picture, ".gif"); break;
- case LC_IMAGE_JPG: strcat(picture, ".jpg"); break;
- case LC_IMAGE_PNG: strcat(picture, ".png"); break;
- }
-
- imopts.background[0] = (unsigned char)(m_fBackground[0]*255);
- imopts.background[1] = (unsigned char)(m_fBackground[1]*255);
- imopts.background[2] = (unsigned char)(m_fBackground[2]*255);
-
- if (animation == 0)
- m_bAnimation = false;
- else if (animation == 1)
- m_bAnimation = true;
-
- if (to < from)
- {
- unsigned short tmp;
- tmp = from;
- from = to;
- to = tmp;
- }
-
- if ((from == 0) && (to == 0))
- {
+ // Update all user interface elements.
+ SystemUpdateUndoRedo(m_pUndoList->pNext ? m_pUndoList->strText : NULL, m_pRedoList ? m_pRedoList->strText : NULL);
+ SystemUpdatePaste(m_pClipboard[m_nCurClipboard] != NULL);
+ SystemUpdatePlay(true, false);
+ SystemUpdateCategories(false);
+ SetTitle(m_strTitle);
+
+ SystemUpdateFocus(NULL);
+ SetAction(m_nCurAction);
+ SystemUpdateViewport(m_nViewportMode, 0);
+ SystemUpdateColorList(m_nCurColor);
+ SystemUpdateAnimation(m_bAnimation, m_bAddKeys);
+ SystemUpdateRenderingMode((m_nDetail & LC_DET_BACKGROUND) != 0, (m_nDetail & LC_DET_FAST) != 0);
+ SystemUpdateSnap(m_nSnap);
+ SystemUpdateSnap(m_nMoveSnap, m_nAngleSnap);
+ SystemUpdateCameraMenu(m_pCameras);
+ SystemUpdateCurrentCamera(NULL, m_pViewCameras[m_nActiveViewport], m_pCameras);
+ UpdateSelection();
if (m_bAnimation)
- from = to = m_nCurFrame;
+ SystemUpdateTime(m_bAnimation, m_nCurFrame, m_nTotalFrames);
else
- from = to = m_nCurStep;
- }
- else if ((from == 0) && (to != 0))
- {
- from = to;
- }
- else if ((from != 0) && (to == 0))
- {
- to = from;
- }
-
- if (m_bAnimation)
- {
- if (from > m_nTotalFrames)
- from = m_nTotalFrames;
-
- if (to > m_nTotalFrames)
- to = m_nTotalFrames;
- }
- else
- {
- if (from > 255)
- from = 255;
-
- if (to > 255)
- to = 255;
- }
-
- Image* images = new Image[to - from + 1];
- CreateImages (images, width, height, from, to, highlight);
-
- for (i = 0; i <= to - from; i++)
- {
- char filename[LC_MAXPATH];
-
- if (from != to)
- {
- char* ext = strrchr (picture, '.');
- *ext = 0;
- sprintf (filename, "%s%02d.%s", picture, i+1, ext+1);
- *ext = '.';
- }
- else
- strcpy (filename, picture);
-
- images[i].FileSave (filename, &imopts);
- }
- delete []images;
+ SystemUpdateTime(m_bAnimation, m_nCurStep, 255);
- return false;
- }
- }
- else
- OnNewDocument();
+ for (int i = 0; i < m_ViewList.GetSize(); i++)
+ {
+ m_ViewList[i]->MakeCurrent();
+ RenderInitialize();
+ }
- return true;
+ UpdateSelection();
}
void Project::SetTitle(const char* lpszTitle)
{
- strcpy(m_strTitle, lpszTitle);
+ if (lpszTitle != m_strTitle)
+ strcpy(m_strTitle, lpszTitle);
char title[LC_MAXPATH], *ptr, ext[4];
- strcpy(title, "LeoCAD - ");
- strcat(title, m_strTitle);
+ strcpy(title, m_strTitle);
ptr = strrchr(title, '.');
if (ptr != NULL)
@@ -444,6 +206,8 @@ void Project::SetTitle(const char* lpszTitle)
*ptr = 0;
}
+ strcat(title, " - LeoCAD");
+
SystemSetWindowCaption(title);
}
@@ -733,7 +497,7 @@ bool Project::FileLoad(File* file, bool bUndo, bool bMerge)
char name[9];
Piece* pPiece = new Piece(NULL);
pPiece->FileLoad(*file, name);
- PieceInfo* pInfo = m_pLibrary->FindPieceInfo(name);
+ PieceInfo* pInfo = lcGetPiecesLibrary()->FindPieceInfo(name);
if (pInfo)
{
pPiece->SetPieceInfo(pInfo);
@@ -772,7 +536,7 @@ bool Project::FileLoad(File* file, bool bUndo, bool bMerge)
const unsigned char conv[20] = { 0,2,4,9,7,6,22,8,10,11,14,16,18,9,21,20,22,8,10,11 };
color = conv[color];
- PieceInfo* pInfo = m_pLibrary->FindPieceInfo(name);
+ PieceInfo* pInfo = lcGetPiecesLibrary()->FindPieceInfo(name);
if (pInfo != NULL)
{
Piece* pPiece = new Piece(pInfo);
@@ -1318,7 +1082,7 @@ void Project::FileReadLDraw(File* file, Matrix* prevmat, int* nOk, int DefColor,
char name[9];
strcpy(name, tmp);
- PieceInfo* pInfo = m_pLibrary->FindPieceInfo(name);
+ PieceInfo* pInfo = lcGetPiecesLibrary()->FindPieceInfo(name);
if (pInfo != NULL)
{
float x, y, z, rot[4];
@@ -1744,7 +1508,7 @@ void Project::SetPathName(const char* lpszPathName, bool bAddToMRU)
// add it to the file MRU list
if (bAddToMRU)
- main_window->AddToMRU (lpszPathName);
+ main_window->AddToMRU (lpszPathName);
}
/////////////////////////////////////////////////////////////////////////////
@@ -1823,7 +1587,7 @@ void Project::Render(bool bToMemory)
#ifdef _DEBUG
#ifdef LC_WINDOWS
-#define BENCHMARK
+//#define BENCHMARK
#endif
#endif
@@ -3182,7 +2946,7 @@ void Project::RenderInitialize()
char filename[LC_MAXPATH];
FileDisk file;
- strcpy (filename, m_pLibrary->GetLibraryPath ());
+ strcpy (filename, lcGetPiecesLibrary()->GetLibraryPath ());
strcat (filename, "sysfont.txf");
if (file.Open (filename, "rb"))
@@ -3621,12 +3385,12 @@ void Project::CreateHTMLPieceList(FILE* f, int nStep, bool bImages, char* ext)
fputs("</tr>\n",f);
PieceInfo* pInfo;
- for (int j = 0; j < m_pLibrary->GetPieceCount (); j++)
+ for (int j = 0; j < lcGetPiecesLibrary()->GetPieceCount (); j++)
{
bool Add = false;
int count[LC_MAXCOLORS];
memset (&count, 0, sizeof (count));
- pInfo = m_pLibrary->GetPieceInfo (j);
+ pInfo = lcGetPiecesLibrary()->GetPieceInfo (j);
for (pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
{
@@ -4226,10 +3990,10 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
PieceInfo* pInfo;
Piece* pPiece;
FILE* f;
- char *conv = (char*)malloc (9*m_pLibrary->GetPieceCount ());
- char *flags = (char*)malloc (m_pLibrary->GetPieceCount ());
- memset (conv, 0, 9*m_pLibrary->GetPieceCount());
- memset (flags, 0, m_pLibrary->GetPieceCount());
+ char *conv = (char*)malloc (9*lcGetPiecesLibrary()->GetPieceCount ());
+ char *flags = (char*)malloc (lcGetPiecesLibrary()->GetPieceCount ());
+ memset (conv, 0, 9*lcGetPiecesLibrary()->GetPieceCount());
+ memset (flags, 0, lcGetPiecesLibrary()->GetPieceCount());
// read LGEO conversion table
if (strlen (opts.libpath))
@@ -4252,7 +4016,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
u = (((unsigned char)(bt[3])|((unsigned short)(bt[2]) << 8))|
(((unsigned long)(bt[1])) << 16)) + bt[0] * 16581375;
sprintf(tmp, "%d", (int)u);
- pInfo = m_pLibrary->FindPieceInfo(tmp);
+ pInfo = lcGetPiecesLibrary()->FindPieceInfo(tmp);
fread(&tmp, 9, 1, f);
if (tmp[8] != 0)
@@ -4260,7 +4024,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
if (pInfo != NULL)
{
- int idx = m_pLibrary->GetPieceIndex (pInfo);
+ int idx = lcGetPiecesLibrary()->GetPieceIndex (pInfo);
memcpy (&conv[idx*9], &tmp[1], 9);
flags[idx] = tmp[0];
}
@@ -4285,12 +4049,12 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
if ((tmp[u] == 0) && (u != 0))
{
u = 0;
- pInfo = m_pLibrary->FindPieceInfo(tmp);
+ pInfo = lcGetPiecesLibrary()->FindPieceInfo(tmp);
fread(&tmp, 8, 1, f);
if (pInfo != NULL)
{
- int idx = m_pLibrary->GetPieceIndex (pInfo);
+ int idx = lcGetPiecesLibrary()->GetPieceIndex (pInfo);
memcpy(&conv[idx*9], tmp, 9);
}
}
@@ -4322,7 +4086,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
if (pNext == pPiece)
{
- int idx = m_pLibrary->GetPieceIndex (pInfo);
+ int idx = lcGetPiecesLibrary()->GetPieceIndex (pInfo);
char pat[] = "patterns/";
if (conv[idx*9+1] != 'p')
strcpy(pat, "");
@@ -4365,7 +4129,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
for (pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
{
pInfo = pPiece->GetPieceInfo();
- int idx = m_pLibrary->GetPieceIndex (pInfo);
+ int idx = lcGetPiecesLibrary()->GetPieceIndex (pInfo);
if (conv[idx*9] != 0)
continue;
@@ -4520,7 +4284,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
{
float fl[12], pos[3], rot[4];
char name[20];
- int idx = m_pLibrary->GetPieceIndex (pPiece->GetPieceInfo ());
+ int idx = lcGetPiecesLibrary()->GetPieceIndex (pPiece->GetPieceInfo ());
if (conv[idx*9] == 0)
{
@@ -4671,16 +4435,16 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
strcpy(opts.strComments, m_strComments);
opts.strFilename = m_strPathName;
- opts.lines = m_pLibrary->GetPieceCount();
- opts.count = (unsigned short*)malloc(m_pLibrary->GetPieceCount()*LC_MAXCOLORS*sizeof(unsigned short));
- memset (opts.count, 0, m_pLibrary->GetPieceCount()*LC_MAXCOLORS*sizeof(unsigned short));
- opts.names = (char**)malloc(m_pLibrary->GetPieceCount()*sizeof(char*));
- for (int i = 0; i < m_pLibrary->GetPieceCount(); i++)
- opts.names[i] = m_pLibrary->GetPieceInfo (i)->m_strDescription;
+ opts.lines = lcGetPiecesLibrary()->GetPieceCount();
+ opts.count = (unsigned short*)malloc(lcGetPiecesLibrary()->GetPieceCount()*LC_MAXCOLORS*sizeof(unsigned short));
+ memset (opts.count, 0, lcGetPiecesLibrary()->GetPieceCount()*LC_MAXCOLORS*sizeof(unsigned short));
+ opts.names = (char**)malloc(lcGetPiecesLibrary()->GetPieceCount()*sizeof(char*));
+ for (int i = 0; i < lcGetPiecesLibrary()->GetPieceCount(); i++)
+ opts.names[i] = lcGetPiecesLibrary()->GetPieceInfo (i)->m_strDescription;
for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
{
- int idx = m_pLibrary->GetPieceIndex (pPiece->GetPieceInfo ());
+ int idx = lcGetPiecesLibrary()->GetPieceIndex (pPiece->GetPieceInfo ());
opts.count[idx*LC_MAXCOLORS+pPiece->GetColor()]++;
}
@@ -4721,7 +4485,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
if (SystemDoDialog(LC_DLG_LIBRARY, NULL))
{
- if (m_pLibrary->m_Modified)
+ if (lcGetPiecesLibrary()->m_Modified)
{
DeleteContents(true);
FileLoad(&file, true, false);
@@ -4878,7 +4642,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
char name[9];
Piece* pPiece = new Piece(NULL);
pPiece->FileLoad(*file, name);
- PieceInfo* pInfo = m_pLibrary->FindPieceInfo(name);
+ PieceInfo* pInfo = lcGetPiecesLibrary()->FindPieceInfo(name);
if (pInfo)
{
pPiece->SetPieceInfo(pInfo);
diff --git a/common/project.h b/common/project.h
index ade05d0..1330303 100644
--- a/common/project.h
+++ b/common/project.h
@@ -57,7 +57,6 @@ public:
// Constructors
Project();
~Project();
- bool Initialize(int argc, char *argv[], char* binpath, char* libpath);
// Attributes
public:
@@ -70,6 +69,8 @@ public:
unsigned char GetLastStep();
bool IsAnimation()
{ return m_bAnimation; }
+ void SetAnimation(bool Anim)
+ { m_bAnimation = Anim; } // only to be called from lcApplication::Initialize()
unsigned short GetCurrentTime ()
{ return m_bAnimation ? m_nCurFrame : m_nCurStep; }
unsigned long GetSnapFlags() const
@@ -102,9 +103,7 @@ public:
*ppLight = m_pLights;
}
- PiecesLibrary* GetPiecesLibrary () const
- { return m_pLibrary; }
-
+ void UpdateInterface();
void SetPathName (const char* lpszPathName, bool bAddToMRU);
void SetTitle (const char* lpszTitle);
@@ -113,6 +112,7 @@ public:
void DeleteContents(bool bUndo); // delete doc items etc
void LoadDefaults(bool cameras);
+ void CreateImages(Image* images, int width, int height, unsigned short from, unsigned short to, bool hilite);
void Render(bool bToMemory);
void SetViewSize(int cx, int cy);
void CheckAutoSave();
@@ -139,7 +139,6 @@ protected:
// Piece library
TexFont* m_pScreenFont;
- PiecesLibrary* m_pLibrary;
// Undo support
LC_UNDOINFO* m_pUndoList;
@@ -194,7 +193,6 @@ protected:
void RenderOverlays(int Viewport);
void RenderBoxes(bool bHilite);
void RenderInitialize();
- void CreateImages(Image* images, int width, int height, unsigned short from, unsigned short to, bool hilite);
void CreateHTMLPieceList(FILE* f, int nStep, bool bImages, char* ext);
inline bool IsDrawing()
diff --git a/common/str.h b/common/str.h
index 658a16e..78192bc 100644
--- a/common/str.h
+++ b/common/str.h
@@ -22,7 +22,7 @@ public:
char GetAt(int index) const
{ return m_pData[index]; }
- char operator[](int index) const
+ char& operator[](int index) const
{ return m_pData[index]; }
void SetAt(int index, char ch)
{ m_pData[index] = ch; }
diff --git a/common/texfont.cpp b/common/texfont.cpp
index b3b7213..a5c3b5d 100644
--- a/common/texfont.cpp
+++ b/common/texfont.cpp
@@ -8,6 +8,7 @@
#include "texture.h"
#include "library.h"
#include "file.h"
+#include "lc_application.h"
#define LC_TEXFONT_FILE_VERSION 1 // LeoCAD 0.74
#define LC_TEXFONT_FILE_HEADER "LeoCAD Texture Font\0\0\0\0\0\0\0\0\0\0\0\0"
@@ -56,7 +57,7 @@ bool TexFont::FileLoad (File& file)
memset (buf, 0, 32);
file.Read (buf, 8);
- m_pTexture = project->GetPiecesLibrary()->FindTexture (buf);
+ m_pTexture = lcGetPiecesLibrary()->FindTexture (buf);
if (m_pTexture == NULL)
{
console.PrintError ("Cannot find texture for font %s.\n", buf);
diff --git a/common/texture.cpp b/common/texture.cpp
index 4957a0e..8c92e67 100644
--- a/common/texture.cpp
+++ b/common/texture.cpp
@@ -10,6 +10,7 @@
#include "globals.h"
#include "image.h"
#include "library.h"
+#include "lc_application.h"
// =============================================================================
// Static functions
@@ -131,7 +132,7 @@ void Texture::Load(bool bFilter)
FileDisk bin;
void* bits;
- strcpy(filename, project->GetPiecesLibrary ()->GetLibraryPath());
+ strcpy(filename, lcGetPiecesLibrary()->GetLibraryPath());
strcat(filename, "textures.bin");
if (!bin.Open(filename, "rb"))
return;
diff --git a/common/typedefs.h b/common/typedefs.h
index 9346fe8..a12882c 100644
--- a/common/typedefs.h
+++ b/common/typedefs.h
@@ -267,7 +267,7 @@ typedef struct
bool truecolor;
unsigned char background[3];
float pause;
- unsigned char format;
+ unsigned int format;
} LC_IMAGE_OPTS;
typedef struct