;$VER:2.52
;installer script by Curt Esser
;last modified JAN 14 1999
;nah, it's not copyrighted  ©
;what could you do with it except install our program?

(complete 0)

;(set @default-dest "WORK:")

; Texts

(set #Intro-Txt
  (cat "\nWelcome to \n"
  "the BeatBox2 v 2.52\n"
  "Hard Disk Installation Script\n\n"
  "BeatBox2 is designed and programmed by:\n\n"
  "James L. Boyd\n"
  "and\n"
  "Curt Esser\n\n"
  "Note: BeatBox2 requires 515,000 bytes of HD space "
  "for a full installation"
))

(set #Locale-Txt
  (cat "Check the Locale file(s) you want to install "
       "in your SYS:Locale/ directory\n\n"
       "NOTE:  It is NOT necessary to do this.\n"
       "Please read the Help section first"
       ))

(set #Locale-Help
  (cat "This section will install the selected "
       "Locale catalogs into your SYS:Locale/ directory.\n\n"
       "It is NOT necessary to do this!\n\n"
       "BeatBox2 will access the Locale files "
       "from it's own directory, so there is really no need "
       "to clutter up your Locale directory unless you "
       "need to have them there for editing.\n\n"
       ))

(set #Warning-Txt
  (cat "Warning !\n\n\n"
  "ReqTools.library not found in SYS:Libs/\n\n\n"
  "You MUST install ReqTools.library before running BeatBox2!"
))

(set #Path-Txt
  (cat "Where would you like to Install BeatBox2?\n "
  "A new directory will be created there"
))

(set #Path-Help
  (cat "\nThis section lets you choose the "
  "target directory to install BeatBox2. \n\n"
  "A new directory named BeatBox2 will be created there\n\n\n"
  @askdir-help
))

(set #Type-Help
  (cat "\nThis section lets you choose the "
  "type of installation to be done.\n\n"
  "If you don't have BeatBox2 installed on your "
  "Hard Drive, or if you want to reset your "
  "preferences to the defaults, select New Installation\n\n"
  "If you already have BeatBox2 installed, select Update\n\n"
  "Any projects you have created "
  "or anything you have added to your BeatBox2 directory "
  "will NOT be damaged by either installation\n\n"
  @askoptions-help))

(set #Copy-Help
  (cat "In order for BeatBox2 to run properly, "
       "you MUST install these files:\n\n"
       "  BeatBox2\n"
       "  BeatBox2.Prefs\n"
       "  Docs\n"
       "  Fonts\n\n"
       "We also recommend installing:\n\n"
       "  Projects\n"
       "  Icons\n"
       "  Catalogs (if necessary)\n\n"
       
))

(set #CopyCat-Help
  (cat "You only need these if you are using "
       "a language other than English as your "
       "Preferred Locale, "
       "or if you use more than one Preferred Locale"
))

(set #Xtra-Txt
  (cat "Select the Extras you would like installed")
)

(set #Xtra-Help
  (cat "Projects: creates a drawer named Projects and "
       "installs two example projects in it\n\n"
       "Icons   : installs a drawer with the Default Project "
       "Icon (needed if you want your projects saved with an "
       "icon attached) and some extra icons")
)  

        

; Main ----------------------------

(message #Intro-Txt)

(IF (NOT (EXISTS "LIBS:reqtools.library"))
    (message #Warning-Txt (all))
)

(complete 10)

                     ; New install or Update ?

(set #InstallType
  (cat "Select the type of Installation")
)
(set OldNew
  (askchoice
     (prompt #InstallType) 
     (help #Type-help)
     (choices
        "New Installation"               ;Bit 0
        "Update existing Installation")  ;Bit 1 
     (default 0)
  )
)

(if (= OldNew $01)

  (set #Path-Txt
    (cat "Where is your current BeatBox2 directory?\n ")
  )
)


(if (= OldNew $01)

  (set #Path-Help
    (cat "Please indicate where your current "
         "BeatBox2 directory is located\n\n"
         @askdir-help)
  )
)



(set target         ; Where to install ? 
  (askdir 
    (prompt #Path-Txt) 
    (help #Path-Help) 
    (default @default-dest) 
    (newpath)
  )
)

(set @default-dest target)

(complete 20)



(set #Extras        ;install extras ?
  
  (set Xtra
    (askoptions
       (prompt #Xtra-Txt) 
       (help #Xtra-Help)
       (choices
          "Projects"           ;Bit $01
          "Icons")             ;Bit $02 
    )
  )
)

(complete 25)

(if (= @user-level 2)

  (set #CatType       ;copy catalogs to Locale: ?
  
    (set Clog
      (askoptions
        (prompt #Locale-Txt) 
        (help #Locale-Help)
        (choices
           "English"               ;Bit $01
           "Français")             ;Bit $02 
        (default 0)
      )
    )
  )
)



(complete 30)


;---- Copy REQUIRED files ---

; - NO choice - these are all required

(copyfiles
  (prompt  "Copying BeatBox2")
  (source "BeatBox2")
  (dest (tackon target "BeatBox2"))
)

(copyfiles
  (prompt  "Copying BeatBox2.Prefs")
  (source "BeatBox2.Prefs")
  (dest (tackon target "BeatBox2"))
)

(copyfiles
  (prompt  "Copying Fonts")
  (source "fonts/")
  (all)
  (dest (tackon target "BeatBox2/fonts"))
)

(complete 40)

(copyfiles
  (prompt  "Copying Docs")
  (source "Docs/")
  (all)
  (dest (tackon target "BeatBox2/Docs"))
)

(IF (NOT 
  (EXISTS (tackon target "BeatBox2/BeatBox2.key")
  ))
    (copyfiles 
      (source "BeatBox2.key")
      (dest (tackon target "BeatBox2/"))
    )
)

;we need to remove any old catalog files!

(IF (EXISTS (tackon target "BeatBox2/catalogs/english/Beatbox2.catalog"))
    (DELETE
     (tackon target "BeatBox2/catalogs/english/BeatBox2.catalog")
    )
)

(IF (EXISTS (tackon target "BeatBox2/catalogs/Français/BeatBox2.catalog"))
    (DELETE
    (tackon target "BeatBox2/catalogs/Français/BeatBox2.catalog")
   )
)    

(IF (EXISTS ( "SYS:Locale/catalogs/Français/BeatBox2.catalog"))
    (DELETE
     ("SYS:Locale/catalogs/Français/BeatBox2.catalog")
    )
)

(IF (EXISTS ( "SYS:Locale/catalogs/english/BeatBox2.catalog"))
    (DELETE
     ("SYS:Locale/catalogs/english/BeatBox2.catalog")
    )
)

  



; -- Copy OPTIONAL Files --

(if (= Clog $00)   ;skip this if they sent 'em to LOCALE:
  (copyfiles
    (prompt  "Copying Locale Catalogs")
    (source "Catalogs/")
    (all)
    (dest (tackon target "BeatBox2/Catalogs"))
    (help #CopyCat-Help)
    (confirm)
  )
)

(complete 50)


(if (bitand Xtra $01)
    (copyfiles
      (prompt "Copying Projects")
      (help @copyfiles-help)
      (source "Projects/")
      (dest (tackon target "BeatBox2/Projects"))
      (confirm)
      (all)
    )
)

(complete 60)

(if (bitand Xtra $02)
    (copyfiles
      (prompt "Copying Icons")
      (help @copyfiles-help)
      (source "Icons/")
      (dest (tackon target "BeatBox2/Icons"))
      (all)
    )
)

(complete 70)


; -- copy catalogs to Locale: if desired  

(if (bitand Clog $01)
    (copyfiles
      (prompt "Copying English Locale")
      (help @copyfiles-help)
      (source "catalogs/English")
      (dest "Locale:catalogs/English/")
      (confirm)
      (all)
    )
)

(complete 80)  

(if (bitand Clog $02)
    (copyfiles
      (prompt "Copying Français Locale")
      (help @copyfiles-help)
      (source "catalogs/Français")
      (dest "Locale:catalogs/Français")
      (confirm)
      (all)
    )
)  



(complete 90)

; -- OK, now the icons if necessary:

;the main drawer icon:

(IF (NOT 
  (EXISTS (tackon target "BeatBox2.info")
  ))
    (copyfiles 
      (source "installicons/BeatBox II.info")
      (dest (target))
      (newname "BeatBox2.info")
      (noposition)
    )
)

(complete 95)

;now the icons for inside the main drawer:

(if 
   (= OldNew 0)   ;only necessary on new install
      (if (EXISTS (tackon target "BeatBox2/BeatBox2.Prefs"))
        (copyfiles 
          (source "installicons/BeatBox2.Prefs.info")
          (dest (tackon target "BeatBox2"))
        )
      ) 
)

(if 
   (= OldNew 0)   ;only necessary on new install
      
      (copyfiles 
         (source "installicons/BeatBox2.info")
         (dest (tackon target "BeatBox2"))
      )
)

(if 
   (= OldNew 0)   ;only necessary on new install
      (if (EXISTS (tackon target "BeatBox2/Icons/"))
        (copyfiles 
           (source "installicons/Icons.info")
           (dest (tackon target "BeatBox2"))
        )
      )  
)

(if 
   (= OldNew 0)   ;only necessary on new install
      (if (EXISTS (tackon target "BeatBox2/Docs/"))
        (copyfiles 
           (source "installicons/Docs.info")
           (dest (tackon target "BeatBox2"))
        )
      )
)


(if 
   (= OldNew 0)   ;only necessary on new install
      (if (EXISTS (tackon target "BeatBox2/Projects/"))
        (copyfiles 
           (source "installicons/Projects.info")
           (dest (tackon target "BeatBox2"))
        )
      )
)


(complete 100)

(exit "\n\nJames and Curt hope you enjoy BeatBox2\n\n" 
      "You will find BeatBox2 v2.52in your\n\n"
      (target)" directory\n\n"
      "\n\nPlease read the docs!"
      (QUIET)

)
