; **** Installscript written by Markus Illenseer        ****
; **** Does various checks now. Please report any error ****
; **** to markus@techfak.uni-bielefeld.de               ****

; **** This script requires the Installer from Commodore
; **** which is available for free.

; **** setting up some global variables

(set ProductName                "ASwarm II")    ; product name
(set ProductBaseName            "ASwarm")       ; product base name
(set VersionNum                 "2.0")          ; product version number
(set GuideFile                  "ASwarm.guide") ; AmigaGuide File

(set OSVersion                  (/ (getversion) 65536))
(set WBVersion                  (/ (getversion "version.library" (resident)) 65536))
(set Dirpath                    "SYS:WBStartup")
(set @dest-dir                  "SYS:WBStartup")
(set MUIVersion                 6)
(set Options                    1) ; 1=english, 2=german, 3=e+g

(set LocLang1                   "english")
(set LocLang2                   "german")
(set Lang1                      "English")
(set Lang2                      "Deutsch")

(transcript "Installing %s Commodity..." ProductName)

(complete 0)

; **** Check last chance

(message "\nShall I proceed with the installation?\n (see help for more)"
        (help   ("Once you press the Proceed button, \"%s\" will be installed. This is your last chance " ProductName)
                ("to abort this procedure without partially installing the selected files.\n")
                ("\n")
                ("After you press Proceed, you can use the Esc key to abort the installation procedure.\n")
        )
)

; **** Check OSVersion

(if (< OSVersion 36)
        (
                (message ("Looks like you are running WB 1.3. If this is true, ")
                         ("please consider to update to WB 2.1 real soon. ")
                         ("\"%s\" does not work with WB 1.3 and below." ProductName)
                )
        )
)

; **** something very subtle :-)

(if (> OSVersion 39)
        (
                (message ("Dear Amiga Developer, \"%s\" hasn't been tested on your " ProductName)
                         ("installed Workbench version V%ld.\n Please test it and report any " OSVersion)
                         ("Bugs to us, when this Workbench is available to the community, thanks!")
                )
        )
)

(complete 10)

; **** Check MUI System

(if (exists ("Libs:MUIMASTER.library"))
        (
                (set muiver (/ (getversion "Libs:MUIMASTER.library") 65536))
                (if (< muiver MUIVersion)
                        (message ("Sorry, your MUI System seems to be too old. " )
                                 ("\"%s\" needs at least MUI 1.4 with library version 6.x " ProductName)
                                 ("You seem to have installed a MUI library version %ld." muiver)
                                 ("Of course you can continue the intallation, but don't forget to ")
                                 ("update your MUI System.")
                        )
                )
        )
        (
                (message ("Sorry, you don't seem to have MUI installed on your ")
                         ("system. Remember that \"%s\" needs it in order to  " ProductName)
                         ("work full flavoured. " ProductName)
                         ("Of course you can continue the intallation, but don't forget to ")
                         ("update to MUI.")
 
                )
        )
)

(complete 20)

; **** Copy Commodity

(copylib
        (help @copylib-help)
        (prompt ("Installing %s %s..." ProductName VersionNum))
        (confirm)
        (source ProductBaseName)
        (infos)
        (noposition)
        (set DirPath
                (askdir 
                        (prompt 
                          ("Please select a place for \"%s\".\n (See help for more)" ProductName)
                        )
                        (help 
                          ("\n")
                          ("About 20K is required for complete installation. ")
                          ("You may install over an older copy of \"%s\" " ProductName)
                          ("to update to this new version - your current ")
                          ("configuration which is stored in the Icon will be deleted though. ")
                          ("\"%s\" and the Icon will be installed in the directory " ProductName)
                          ("of your choice. You may wish to create a new directory ")
                          ("for \"%s\" by using the 'Make New Drawer' gadget. " ProductName)
                          ("Best place for \"%s\" is SYS:WbStartup, as \"%s\" will " ProductName ProductName)
                          ("be started automatically on boot time as Commodity.")
                          ("\n\n")
                          @askdir-help
                        )
                        (default "SYS:WBstartup")
                        (newpath)
                )
        )
        (dest DirPath)
)

(complete 50)

; **** Ask GuideFiles

(set Options
(askoptions
        (prompt
                ("Select the localized Guidefiles you want to install at this time\n")
        )
        (help
                ("You click on the desired language to install the selected Guidefiles.\n\n")
                @askoptions-help
        )
        (choices
                ("English Online Manual")
                ("Deutsche Sofort-Anleitung")
        (default Options)
        )
)
)

(complete 60)

(if (IN Options 0)
        (
                (if (<> (exists "libs:amigaguide.library"))
                        (message "I couldn't locate \"amigaguide.libary\" on your system, you probably won't be able to use online help.")
                )
                (copyfiles
                        (prompt "Installing the %s online help..." LocLang1)
                        (source ("%s/%s" Lang1 GuideFile))
                        (help @copyfiles-help)
                        (dest
                                (set manpath (askdir
                                        (prompt "Please select a place for the english online help.\n")
                                        (help 
                                                ("The Guidefile \"%s\" will be copied to the appropriate place, " GuideFile)
                                                ("which normally is the HELP: directory on your SYS: partition.")
                                                ("You may want to install the package into a directory of its own, ")
                                                ("but then you need to enhance the search parth for AmigaGuide. Please refer to the Manual.")
                                                ("\n")
                                                @askdir-help
                                        )
                                        (default ("HELP:%s" Lang1))
                                        (newpath)
                                ))
                        )
                )
        )
)


(complete 70)

; **** Copy GuideFiles

(if (IN Options 1)
        (
                (if (<> (exists "libs:amigaguide.library"))
                        (message "I couldn't locate \"amigaguide.libary\" on your system, you probably won't be able to use online help.")
                )
                (copyfiles
                        (prompt "Installing the %s online help..." LocLang2)
                        (source ("%s/%s" Lang2 GuideFile))
                        (help @copyfiles-help)
                        (dest
                                (set manpath (askdir
                                        (prompt "Please select a place for the german help.\n")
                                        (help 
                                                ("The Guidefile \"%s\" will be copied to the appropriate place, " GuideFile)
                                                ("which normally is the HELP: directory on your SYS: partition.")
                                                ("You may want to install the package into a directory of its own, ")
                                                ("but then you need to enhance the search parth for AmigaGuide. Please refer to the Manual.")
                                                ("\n")
                                                @askdir-help
                                        )
                                        (default ("HELP:%s" Lang2))
                                        (newpath)
                                ))
                        )
                )
        )
)

(complete 90)

; **** Check installation

(if (exists (("SYS:WBstartup/%s" ProductBaseName)))
        (
                (message 
                        ("Looks like you have installed \"%s\" in the SYS:WbStartup-Drawer, fine.\n" ProductName)
                        ("This means we don't have to bother about how \"%s\" is started." ProductName)
                )
        )
        (
                (startup
                        (prompt 
                                (("Add \"Run >NIL: %s/%s\" to \"S:user-startup\"? (see help for more)" DirPath ProductBaseName))
                        )
                        (ProductBaseName)
                        (help   
                                ("Select the Proceed button to add the Line\n")
                                ("\"Run >NIL: %s/%s\" " DirPath ProductBaseName)
                                ("This will start \"%s\" automatically on boot time. " ProductName)
                                ("You are requested to do this, because it looks like ")
                                ("you don't have \"%s\" installed in the SYS:WBstartup-drawer." ProductName)
                                ("\n\n")
                                @startup-help)
                        (command ("Run >NIL: %s/%s" DirPath ProductBaseName))
                )
        )
)


(complete 99)

; **** Ready

(exit)
