@@ -2374,7 +2374,7 @@ void LDViewWindow::showLibraryUpdateWindow(bool initialInstall)
2374
2374
}
2375
2375
}
2376
2376
2377
- bool LDViewWindow::installLDraw (void )
2377
+ bool LDViewWindow::installLDraw (const std::string& ldrawZipPath )
2378
2378
{
2379
2379
if (libraryUpdater)
2380
2380
{
@@ -2383,12 +2383,19 @@ bool LDViewWindow::installLDraw(void)
2383
2383
}
2384
2384
else
2385
2385
{
2386
- std::string ldrawParentDir = getLDrawDir ();
2387
- std::string ldrawDir = ldrawParentDir;
2386
+ std::string ldrawDir;
2388
2387
UCCHAR originalDir[MAX_PATH];
2389
2388
2390
2389
libraryUpdateFinished = false ;
2391
- ldrawDir += " \\ LDRAW" ;
2390
+ if (ldrawZipPath.empty ())
2391
+ {
2392
+ std::string ldrawParentDir = getLDrawDir ();
2393
+ combinePath (ldrawParentDir, " LDRAW" , ldrawDir);
2394
+ }
2395
+ else
2396
+ {
2397
+ ldrawDir = getLDrawDir ();
2398
+ }
2392
2399
GetCurrentDirectory (COUNT_OF (originalDir), originalDir);
2393
2400
ucstring ucLDrawDir;
2394
2401
utf8toucstring (ucLDrawDir, ldrawDir);
@@ -2403,6 +2410,7 @@ bool LDViewWindow::installLDraw(void)
2403
2410
libraryUpdater = new LDLibraryUpdater;
2404
2411
libraryUpdateCanceled = false ;
2405
2412
libraryUpdater->setLibraryUpdateKey (LAST_LIBRARY_UPDATE_KEY);
2413
+ libraryUpdater->setLdrawZipPath (ldrawZipPath);
2406
2414
libraryUpdater->setLdrawDir (ldrawDir.c_str ());
2407
2415
libraryUpdater->installLDraw ();
2408
2416
showLibraryUpdateWindow (true );
@@ -2417,6 +2425,16 @@ bool LDViewWindow::installLDraw(void)
2417
2425
}
2418
2426
if (libraryUpdateFinished)
2419
2427
{
2428
+ if (ldrawZipPath.empty ())
2429
+ {
2430
+ TCUserDefaults::removeValue (LDRAWZIP_KEY, false );
2431
+ }
2432
+ else
2433
+ {
2434
+ TCUserDefaults::setPathForKey (ldrawZipPath.c_str (), LDRAWZIP_KEY, false );
2435
+ }
2436
+ TCUserDefaults::setPathForKey (ldrawDir.c_str (), LDRAWDIR_KEY, false );
2437
+ LDLModel::setLDrawZipPath (ldrawZipPath);
2420
2438
LDLModel::setLDrawDir (ldrawDir.c_str ());
2421
2439
}
2422
2440
return libraryUpdateFinished;
@@ -3681,7 +3699,7 @@ BOOL LDViewWindow::verifyLDrawDir(bool forceChoose)
3681
3699
3682
3700
if (!forceChoose &&
3683
3701
(!TCUserDefaults::longForKey (VERIFY_LDRAW_DIR_KEY, 1 , false ) ||
3684
- verifyLDrawDir (lDrawDir)))
3702
+ (!lDrawDir. empty () && verifyLDrawDir (lDrawDir) )))
3685
3703
{
3686
3704
found = TRUE ;
3687
3705
}
@@ -3714,22 +3732,38 @@ BOOL LDViewWindow::verifyLDrawDir(bool forceChoose)
3714
3732
if (MessageBox (NULL , ls (_UC (" WillDownloadLDraw" )),
3715
3733
_UC (" LDView" ), MB_OKCANCEL | MB_ICONINFORMATION) == IDOK)
3716
3734
{
3717
- LDLModel::setLDrawDir (" C:\\ " );
3718
- if (promptForLDrawDir (
3719
- ls (_UC (" LDrawInstallDirPrompt" ))))
3720
- {
3721
- if (installLDraw ())
3722
- {
3723
- found = true ;
3724
- }
3725
- }
3735
+ found = findAndInstallLDraw ();
3726
3736
}
3727
3737
}
3728
3738
#endif // !_NO_BOOST
3729
3739
}
3730
3740
return found;
3731
3741
}
3732
3742
3743
+ bool LDViewWindow::findAndInstallLDraw (void )
3744
+ {
3745
+ LDLModel::setLDrawDir (" C:\\ " );
3746
+ if (MessageBox (NULL , ls (_UC (" InstallZipMessage" )), ls (_UC (" InstallZipTitle" )), MB_YESNO | MB_ICONQUESTION) == IDYES)
3747
+ {
3748
+ if (promptForLDrawDir (ls (_UC (" LDrawZipInstallDirPrompt" ))))
3749
+ {
3750
+ std::string ldrawDir = LDLModel::lDrawDir ();
3751
+ std::string ldrawZipPath;
3752
+ combinePath (ldrawDir, " complete.zip" , ldrawZipPath);
3753
+ return installLDraw (ldrawZipPath);
3754
+ }
3755
+ }
3756
+ else
3757
+ {
3758
+ if (promptForLDrawDir (
3759
+ ls (_UC (" LDrawInstallDirPrompt" ))))
3760
+ {
3761
+ return installLDraw ();
3762
+ }
3763
+ }
3764
+ return false ;
3765
+ }
3766
+
3733
3767
std::string LDViewWindow::lastOpenPath (char * pathKey)
3734
3768
{
3735
3769
if (!pathKey)
0 commit comments