Added option to set an extra path to scan for the LDraw library.

This commit is contained in:
leo 2014-09-12 22:47:08 +00:00
parent 62cec48d93
commit c0db665346
4 changed files with 57 additions and 42 deletions

View file

@ -64,37 +64,28 @@ void lcApplication::SetClipboard(lcFile* Clipboard)
gMainWindow->UpdatePaste(mClipboard != NULL);
}
bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LibraryCachePath)
bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LDrawPath, const char* LibraryCachePath)
{
if (mLibrary == NULL)
mLibrary = new lcPiecesLibrary();
if (LibPath && LibPath[0])
{
if (mLibrary->Load(LibPath, LibraryCachePath))
return true;
}
else
{
return mLibrary->Load(LibPath, LibraryCachePath);
char* EnvPath = getenv("LEOCAD_LIB");
if (EnvPath && EnvPath[0])
{
if (mLibrary->Load(EnvPath, LibraryCachePath))
return true;
return mLibrary->Load(EnvPath, LibraryCachePath);
}
else
{
char CustomPath[LC_MAXPATH];
char CustomPath[LC_MAXPATH];
strcpy(CustomPath, lcGetProfileString(LC_PROFILE_PARTS_LIBRARY));
if (CustomPath[0])
{
if (mLibrary->Load(CustomPath, LibraryCachePath))
return true;
}
else if (LibraryInstallPath && LibraryInstallPath[0])
return mLibrary->Load(CustomPath, LibraryCachePath);
if (LibraryInstallPath && LibraryInstallPath[0])
{
char LibraryPath[LC_MAXPATH];
@ -112,7 +103,19 @@ bool lcApplication::LoadPiecesLibrary(const char* LibPath, const char* LibraryIn
return true;
}
}
}
if (LDrawPath && LDrawPath[0])
{
char LibraryPath[LC_MAXPATH];
strcpy(LibraryPath, LDrawPath);
int i = strlen(LibraryPath) - 1;
if ((LibraryPath[i] != '\\') && (LibraryPath[i] != '/'))
strcat(LibraryPath, "/");
if (mLibrary->Load(LibraryPath, LibraryCachePath))
return true;
}
return false;
@ -150,7 +153,7 @@ void lcApplication::ParseStringArgument(int* CurArg, int argc, char* argv[], cha
}
}
bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstallPath, const char* LibraryCachePath)
bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstallPath, const char* LDrawPath, const char* LibraryCachePath)
{
char* LibPath = NULL;
@ -240,7 +243,7 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal
}
}
if (!LoadPiecesLibrary(LibPath, LibraryInstallPath, LibraryCachePath))
if (!LoadPiecesLibrary(LibPath, LibraryInstallPath, LDrawPath, LibraryCachePath))
{
if (SaveImage)
{

View file

@ -38,11 +38,11 @@ public:
lcApplication();
~lcApplication();
bool Initialize(int argc, char *argv[], const char* LibraryInstallPath, const char* LibraryCachePath);
bool Initialize(int argc, char *argv[], const char* LibraryInstallPath, const char* LDrawPath, const char* LibraryCachePath);
void Shutdown();
void ShowPreferencesDialog();
bool LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LibraryCachePath);
bool LoadPiecesLibrary(const char* LibPath, const char* LibraryInstallPath, const char* LDrawPath, const char* LibraryCachePath);
void OpenURL(const char* URL);
void RunProcess(const char* ExecutablePath, const lcArray<String>& Arguments);

View file

@ -48,7 +48,6 @@ unix:!macx {
isEmpty(DESKTOP_DIR):DESKTOP_DIR = $$INSTALL_PREFIX/share/applications
isEmpty(MIME_DIR):MIME_DIR = $$INSTALL_PREFIX/share/mime/packages
isEmpty(MIME_ICON_DIR):MIME_ICON_DIR = $$INSTALL_PREFIX/share/icons/hicolor/scalable/mimetypes
isEmpty(DISABLE_UPDATE_CHECK):DISABLE_UPDATE_CHECK = 0
target.path = $$BIN_DIR
docs.path = $$DOCS_DIR
@ -67,7 +66,14 @@ unix:!macx {
INSTALLS += target docs man desktop icon mime mime_icon
DEFINES += LC_INSTALL_PREFIX=\\\"$$INSTALL_PREFIX\\\"
!isEmpty(DISABLE_UPDATE_CHECK) {
DEFINES += LC_DISABLE_UPDATE_CHECK=$$DISABLE_UPDATE_CHECK
}
!isEmpty(LDRAW_LIBRARY_PATH) {
DEFINES += LC_LDRAW_LIBRARY_PATH=\\\"$$LDRAW_LIBRARY_PATH\\\"
}
}
macx {

View file

@ -152,7 +152,13 @@ int main(int argc, char *argv[])
QByteArray pathArray = bundlePath.absolutePath().toLocal8Bit();
const char* libPath = pathArray.data();
#else
const char* libPath = LC_INSTALL_PREFIX"/share/leocad/";
const char* libPath = LC_INSTALL_PREFIX "/share/leocad/";
#endif
#ifdef LC_LDRAW_LIBRARY_PATH
const char* LDrawPath = LC_LDRAW_LIBRARY_PATH;
#else
const char* LDrawPath = NULL;
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
@ -165,7 +171,7 @@ int main(int argc, char *argv[])
QDir dir;
dir.mkpath(cachePath);
if (!g_App->Initialize(argc, argv, libPath, cachePath.toLocal8Bit().data()))
if (!g_App->Initialize(argc, argv, libPath, LDrawPath, cachePath.toLocal8Bit().data()))
return 1;
lcQMainWindow w;