; Imp Professional installation script v0.5ß

(set newvernum (getversion "ImpPro"))
(set newver (/ newvernum 65536))
(set newrev (- newvernum (* newver 65536)))
(set exec-version (/ (getversion) 65536))

(set is_update 0)
(set oldver 0)
(set oldrev 0)
(set appname "Imp_Professional")
(set imppro-dest (getassign "ImpPro" "a"))
(complete 0)

(if imppro-dest
   (
      (set oldvernum (getversion "ImpPro:ImpPro"))
      (set oldver (/ oldvernum 65536))
      (set oldrev (- oldvernum (* oldver 65536)))
   )
)

(if imppro-dest
   (
      (set @default-dest imppro-dest)
      (set is_update 
         (askbool
            (prompt 
               "Your current copy of " appname " v" oldver "." oldrev "ß appears to be located in the drawer named \""
               imppro-dest
               "\".\n\n  Do you want the update (v" newver "." newrev "ß) installed in that drawer?"
            )
            (help
               "The logical assignment \"ImpPro\" is present on your system.  "
               "If you would like this version placed elsewhere, please select"
               " No.  Otherwise, select Yes to install " appname " there."
            )
            (default 1)
         )
      )
   )
)

(if (= is_update 0)
   (
      (set imppro-dest
         (tackon 
            (askdir
               (prompt "In which disk or drawer should " appname " be installed?")
               (help @askdir-help)
               (default @default-dest)
            )
            "ImpPro"
         )
      )
      (makedir imppro-dest (infos))
      (set @default-dest imppro-dest)
      (makeassign "ImpPro" imppro-dest)
   )
)

(complete 5)

(copylib
   (prompt "Copying \"imppro.library\" to your LIBS: assign.")
   (source "Libs/imppro.library")
   (dest "LIBS:")
   (help "The ImpPro shared library is needed by all of the standard modules.")
   (confirm)
)

(complete 10)

(copylib
   (prompt "Copying \"bgui.library\" to your LIBS: assign.")
   (source "Libs/bgui.library")
   (dest "LIBS:")
   (help "BGUI library is needed for layout of the modules' GUIs.  It is copyrighted by Jan.van.den.Baard")
   (confirm)
)

(complete 15)

(copyfiles
   (source "")
   (dest imppro-dest)
   (pattern "#?.txt")
)

(complete 25)

(copyfiles
   (source "")
   (dest imppro-dest)
   (pattern "ImpPro#?")
)

(complete 40)

(copyfiles
   (source "")
   (dest imppro-dest)
   (pattern "#?.info")
)
(delete (tackon imppro-dest "Install-ImpPro.info"))

(complete 50)

(makedir (tackon imppro-dest "Modules"))
(complete 52)
(makedir (tackon imppro-dest "Tables"))
(complete 55)
(makedir (tackon imppro-dest "Data"))
(complete 56)
(makedir (tackon imppro-dest "Data/ExtMonsterData"))
(complete 57)
(makedir (tackon imppro-dest "Save"))
(complete 58)
(makedir (tackon imppro-dest "Scripts"))
(complete 59)
(makedir (tackon imppro-dest "Developer"))
(complete 60)

(copyfiles
   (prompt "Please select the " appname " standard modules to install.")
   (help "Each of these modules provides a service to the DM.  It is recommended that you install all of these.")
   (source "Modules")
   (dest (tackon imppro-dest "Modules"))
   (pattern "#?.mod")
   (confirm)
   (infos)
)

(complete 70)

(copyfiles
   (prompt "Please select the " appname " standard tables to install.")
   (help "To use these tables, you must have Multiview or AmigaGuide installed.")
   (source "Tables")
   (dest (tackon imppro-dest "Tables"))
   (pattern "#?.guide")
   (confirm)
   (infos)
)

(complete 75)

(copyfiles
   (prompt "Please select the " appname " example AREXX script files to install.")
   (help "These files contain example AREXX script files that can be executed by their respective modules.")
   (source "Scripts")
   (dest (tackon imppro-dest "Scripts"))
   (all)
   (confirm)
   (infos)
)

(complete 80)

(copyfiles
   (prompt "Please select the " appname " example save files to install.")
   (help "These files contain example files that can be loaded into their respective modules.")
   (source "Save")
   (dest (tackon imppro-dest "Save"))
   (all)
   (confirm)
   (infos)
)

(complete 85)

(copyfiles
   (prompt "Please select the " appname " example data files to install.  "
           "** If you have modified any of these, you may not wish to overwrite "
           "them at this time! **")
   (help "These files contain data files necessary for the launcher and modules."
         "  If you have modified any of these in a previous version, you may not"
         " want to overwrite them!")
   (source "Data")
   (dest (tackon imppro-dest "Data"))
   (all)
   (confirm)
   (infos)
)

(complete 87)

(copyfiles
   (prompt "Please select the " appname " extended monster data files to install.  "
           "** If you have modified any of these, you may not wish to overwrite "
           "them at this time! **")
   (help "These files contain external data files necessary for viewing monster "
         "pictures or long descriptions")
   (source "Data/ExtMonsterData")
   (dest (tackon imppro-dest "Data/ExtMonsterData"))
   (all)
   (confirm)
   (infos)
)

(complete 90)

(copyfiles
   (prompt "Please select the " appname " example developer files to install.  "
           "These files show you how to program your own module for ImpPro.")
   (help "If you are a programmer, you'll probably want to install these.")
   (source "Developer")
   (dest (tackon imppro-dest "Developer"))
   (all)
   (confirm)
   (infos)
)

(complete 95)

(if (> exec-version 38)
   ( (tooltype
       (prompt "Workbench 3.0+ detected, change default tool of ALL Imp Pro guide files and dock buttons to Multiview?")
       (help "If you have Workbench 3.0+, you'll want to do this...Trust me  :)")
       (dest (tackon imppro-dest "ImpPro.guide"))
       (setdefaulttool "Multiview")
       (confirm))
     (if (exists (tackon imppro-dest "Tables/Tables.guide"))
        (tooltype
           (dest (tackon imppro-dest "Tables/Tables.guide"))
           (setdefaulttool "Multiview")))
     (if (exists (tackon imppro-dest "Tables/Spells.guide"))
        (tooltype
           (dest (tackon imppro-dest "Tables/Spells.guide"))
           (setdefaulttool "Multiview")))
     (if (exists (tackon imppro-dest "Tables/Swords.guide"))
        (tooltype
           (dest (tackon imppro-dest "Tables/Swords.guide"))
           (setdefaulttool "Multiview")))
     (if (exists (tackon imppro-dest "Tables/Poisons.guide"))
        (tooltype
           (dest (tackon imppro-dest "Tables/Poisons.guide"))
           (setdefaulttool "Multiview")))
     (if (exists (tackon imppro-dest "Tables/Prices.guide"))
        (tooltype
           (dest (tackon imppro-dest "Tables/Prices.guide"))
           (setdefaulttool "Multiview")))
     (delete (tackon imppro-dest "Data/Default.dock"))
     (rename (tackon imppro-dest "Data/Default.dock30")
	     (tackon imppro-dest "Data/Default.dock"))
   )
)

(complete 97)

; Delete obsolete junk!

(if (exists (tackon imppro-dest "ImpPro.prefs"))
   (delete (tackon imppro-dest "ImpPro.prefs")))
(if (exists (tackon imppro-dest "Data/ImpPro.menu"))
   (delete (tackon imppro-dest "Data/ImpPro.menu#?")))
(if (exists (tackon imppro-dest "Data/ImpPro.menu30"))
   (delete (tackon imppro-dest "Data/ImpPro.menu30#?")))
(if (exists (tackon imppro-dest "Data/Dice.data"))
   (delete (tackon imppro-dest "Data/Dice.data#?")))
(if (exists (tackon imppro-dest "Save/test.clock"))
   (delete (tackon imppro-dest "Save/#?.clock")))
(if (exists (tackon imppro-dest "Save/test.chrlist"))
   (delete (tackon imppro-dest "Save/#?.chrlist")))
(if (exists (tackon imppro-dest "Modules/Experience.mod"))
   (delete (tackon imppro-dest "Modules/Experience.mod#?")))

(complete 99)

(startup appname
   (prompt
      "Ready to modify \"S:User-Startup\" so that " appname " can be "
      "used with your system."
   )
   (help @startup-help)
   (command 
      "Assign ImpPro: " imppro-dest "\n"
   )
)

(complete 100)

(exit)
