(complete 0)

;Check kickver
(if (< (/ (getversion) 65536) 37)
   (abort ("\nYou must have kickstart 2.04+ to run Icon Deluxe")
   )
)

(set sdir (pathonly @icon))

(set @default-dest "SYS:Tools")

(set ID_dest (askdir
      (prompt "Where should Icon Deluxe be installed?")
      (help "Select a drawer where you want to install Icon Deluxe")
      (default @default-dest)
   )
)
(set ans (askbool 
   (
      (prompt "\nDo you want to make a new drawer called Icon Deluxe?  "
               "(Please note that the documentation is the only other "
               "file, and it may be placed elsewhere if you wish)")
         (help "")
      )
   )
)
(if (= 1 ans)
   (
      (makedir (tackon ID_dest "Icon Deluxe") (infos))
      (set ID_dest (tackon ID_dest "Icon Deluxe"))
   )
)

(set @default-dest ID_dest)

(working ("Copying Icon Deluxe"))
(copyfiles
   (source (tackon sdir "IconDeluxe"))
   (dest ID_dest)
   (help @copyfiles-help)
   (infos)
)
(complete 40)
(set Doc_dest (askdir
      (prompt "Where should Icon Deluxe's documentation be installed?")
      (help "Select a drawer where you want to install the docs")
      (default @default-dest)
   )
)
(copyfiles
   (source (tackon sdir "IconDeluxe.guide"))
   (dest Doc_dest)
   (help @copyfiles-help)
   (infos)
)
(complete 50)
(copyfiles
   (source (tackon sdir "IDSetTT"))
   (dest "T:")
   (help @copyfiles-help)
   (infos)
)
(run "T:IDSetTT >CON:0/0/400/100/IDSetTT/AUTO/CLOSE/WAIT \"#1@"
   (tackon ID_dest "IconDeluxe") "\" \"#2@" 
   (tackon Doc_dest "IconDeluxe.guide") "\"")
(run "delete T:IDSetTT")
(if (exists "S:IDHelpFile"))
   (
      (run "delete S:IDHelpFile")
   )
(if (exists "ENV:IDDataFile"))
   (
      (run "delete ENV:IDDataFile")
   )
(if (exists "ENVARC:IDDataFile"))
   (
      (run "delete ENVARC:IDDataFile")
   )
(complete 60)
(if (exists (tackon sdir "Source"))
   (
      (set ans (askbool
         (
            (prompt "Do you wish to also install the source code in "
                    ID_dest"?  I recommend keeping it elsewhere.")
            (help "If you select no, then you will be able to choose "
                  "another location for the source code, but it will be "
                  "necessary to place a second copy of the Icon Deluxe "
                  "executable there.  This is advantageous because it "
                  "allows you to have a copy that you're working on while "
                  "maintaining a fully functional version in" ID_dest ".")
         )
      ))
      (if (= 1 ans)
         (
            (working ("Copying source code"))
            (copyfiles
               (source (tackon sdir "Source/"))
               (dest (tackon ID_dest "Source"))
               (help @copyfiles-help)
               (infos)
               (all)
            )
         )
      )
      (if (= 0 ans)
         (
            (set Src_dest
               (askdir
                  (prompt "Where should the source code be installed?  A "
                          "drawer called \"Icon Deluxe\" will be created "
                          "which will contain another drawer called "
                          "Source and a copy of the executable.")
                  (help ("Select a drawer where you want to install the "
                         "source code"))
                  (default "")
               )
            )
            (makedir (tackon Src_dest "Icon Deluxe") (infos))
            (set Src_dest (tackon Src_dest "Icon Deluxe"))
            (working ("Copying source code"))
            (copyfiles
               (source (tackon sdir "IconDeluxe"))
               (dest Src_dest)
               (help @copyfiles-help)
               (infos)
            )
            (complete 65)
            (copyfiles
               (source (tackon sdir "Source/"))
               (dest (tackon Src_dest "Source"))
               (help @copyfiles-help)
               (infos)
               (all)
            )
         )
      )
   )
)

(complete 100)

(exit)
