; $VER: Install_AWeb 3.4SE (24.11.2000)
; Description: Installer script for AWeb-II 3.4 Special Edition

(set v44 (>= (/ (getversion "workbench.library" (resident)) 65536) 44))

; all strings used in this installer script

(set #need44 "This program requires OS 3.5 or later to function.")
(set #nohelp "No help available.")
(set #welcome
   (cat "AWeb-II is a fast, multithreaded World Wide Web browser for Amiga OS 3.0 or higher.\n"
      "It understands virtually all widely used HTML including JavaScript and has many other features.\n"
      "AWeb-II runs with a wide variety of TCP-stacks."
      "\n\nThis installation procedure will install a Special Edition of the AWeb-II browser "
      "for use with the Amiga OS 3.9 on your system."
   )
)

(set #has3x
   (cat "You seem to have AWeb-II version %ld.%ld already installed on your system.\n"
      "This Special Edition offers only a subset of the functionality featured by "
      "the full version of AWeb-II."
   )
)
(set #upgrade3x
   (cat "\n\nYou are advised to upgrade to the latest AWeb-II version 3.x.\n"
      "You can download a free upgrade archive from the Amitrix web site:\n"
      "http://www.amitrix.com/aweb.html\n"
      "(use the \"Help / AWeb home page\" menu item in AWeb-II)."
   )
)
(set #cont3x "\n\nDo you want to install this Special Edition anyway?")
(set #cont3x-help
   (cat "If you choose Yes, this Special Edition will be installed on your machine "
      "even though you have already a full version of AWeb-II installed.\n\n"
      "If you choose No, this installation will be cancelled.\n\n"
   )
)
(set #exit3x "Installation cancelled")

(set #destdir-prompt
   (cat "Please select the directory where you want AWeb-II installed.\n"
      "(A directory \"AWeb3SE\" will be created there.)"
   )
)
(set #destdir-help
   (cat "Select the location where a directory for AWeb-II Special Edition "
      "should be created.\n\n"
      @askdir-help
   )
)
(set #installing "Installing ")
(set #languages-prompt "Please select which language catalog(s) you want to install")
(set #missing-msg
   (cat "At the time of release, the following language translations were not ready yet.\n"
      "As soon as they are completed, they will be available for download from the Amitrix "
      "website: http://www.amitrix.com/aweb.html\n"
      "(use the \"Help / AWeb home page\" menu item in AWeb-II).\n\nMissing languages:"
   )
)

(set #fonts-prompt "Do you want to install the \"times.font\" and \"courier.font\" sizes 30 and 36?")
(set #fonts-help 
   (cat "In order to provide AWeb-II with a consistent set of fonts, four fonts are included "
      "in this archive, times/30, times/36, courier/30 and courier/36.\n\n"
      "Because AWeb-II uses these fonts by default, headers might look really awful "
      "if you don't install these fonts. It is highly recommended that you install them.\n\n"
   )   
)
(set #fixfonts-prompt "The FixFonts utility will be run to make the newly added fonts available.")
(set #fixfonts-help
   (cat "The FixFonts utility is needed to make the newly added fonts available to the system.\n\n"
      "If you intend to use the fonts from this archive, you are strongly encouraged to "
      "run FixFonts now.\n\n"
      "Note that running this program may take a while."
   )
)

(set #picassowarning
   (cat "IMPORTANT NOTE for users of Picasso 96 graphics software.\n\n"
      "At the time of release of this version of AWeb-II SE, the Picasso96 software contains "
      "a known bug that might crash your system when viewing scaled images.\n\n"
      "If you experience system crashes during the use of AWeb-II SE, we advise you to turn "
      "off progressive display in the image plugins. See the documentation of the image "
      "plugins for further details. This documentation can be found in the \"AWebPlugin/Docs\" "
      "drawer."
   )
)

(set #start-copy
   (cat "Installer now has enough information to start copying the files for "
      "AWeb-IISpecialEdition.\n\n"
      "=============Summary:=============\n\n"
      "------Destinationdirectory:------\n%s\n\n"
      "------------Languages:------------\n%s\n\n"
      "------Installspecialfonts:------\n%s"
   )
)

(set #readme "Displaying the Readme file...")
(set #bye 
   (cat "In case you need help using AWeb-II Special Edition, pressing the HELP key "
      "when AWeb is active will bring up the documentation.\n"
      "I hope you will enjoy using this Special Edition and will consider upgrading "
      "to the full version."
   )
)

; ---------------------------------------------------------------------------

(complete 0)

(if (not v44)
   (abort #need44)
)

(set #defdir "Work:")
(set #languages 1)

(trace)
(message #welcome)

; See if AWeb 3.x already installed
(if (exists "AWeb3:AWeb-II" (noreq))
   (
      (set #veraweb (getversion "AWeb3:AWeb-II"))
      (if (>= #veraweb (* 65536 3))
         (
            (set #verv (/ #veraweb 65536))
            (set #verr (- #veraweb (* #verv 65536)))
            (set #msg (#has3x #verv #verr))
            (if (< #veraweb (+ (* 65536 3) 3))
               (
                  (set #msg (cat #msg #upgrade3x))
               )
            )
            (if
               (askbool
                  (prompt (cat #msg #cont3x))
                  (help #cont3x-help)
                  (default 0)
               )
               (
                  (set #dummy 1)
               )
               (
                  (exit #exit3x (quiet))
               )
            )
         )
      )
   )
)

(trace)
(set #defdir
   (askdir
      (prompt #destdir-prompt)
      (help #destdir-help)
      (default #defdir)
      (back (retrace))
   )
)
(set @default-dest #defdir)

(set @default-dest (tackon @default-dest "AWeb3SE"))

(set #update-aweb (exists @default-dest))

(trace)
(set #languages
   (askoptions
      (choices "English" "Catal" "Czech" "Dansk" "Deutsch"
         "Espaol" "Franais" "Hrvatski" "Italiano" "Magyar" "Nederlands" "Norsk"
         "Polski" "Portugus" "Portugus-Brasil" "Russian"
         "Slovensko" "Srpski" "Suomi" "Svenska" "Trke")
      (prompt #languages-prompt)
      (help @askoptions-help)
      (default #languages)
      (back (retrace))
   )
)

(set #missing "")
(set #langnames "English")
(if (bitand #languages 65534)
   (
      (set #bit 2)    ; English implementation, so there is no catalog for it
      (set #langnr 1)
      (while (< #langnr 32)
         (if (bitand #languages #bit)
            (
               (set #lang
                  ; English is never selected from this list
                  (select #langnr "English" "Catal" "Czech" "Dansk" "Deutsch"
                     "Espaol" "Franais" "Hrvatski" "Italiano" "Magyar" "Nederlands" "Norsk"
                     "Polski" "Portugus" "Portugus-Brasil" "Russian"
                     "Slovensko" "Srpski" "Suomi" "Svenska" "Trke"
                  )
               )
               (if (exists (tackon "Catalogs" #lang))
                  (
                     (set #langnames (cat #langnames ", " #lang))
                  )
                  (
                     (set #missing (cat #missing " " #lang))
                  )
               )
            )
         )
         (set #bit (shiftleft #bit 1))
         (set #langnr (+ #langnr 1))
      )
   )
)

(if (<> #missing "")
   (
      (message
         (cat #missing-msg #missing)
      )
   )
)

(set #beenhere 0)
(trace)
; Only ask if fonts should be installed in expert mode
(if (< @user-level 2)
   (
      (if #beenhere (retrace))
      (set #fonts 1)
   )
   (
      (set #fonts
         (askbool
            (prompt #fonts-prompt)
            (help #fonts-help)
            (default 1)
            (back (retrace))
         )
      )
   )
)
(set #beenhere 1)

(complete 10)

(trace)
(message
   (#start-copy @default-dest #langnames
      (select #fonts "No" "Yes")
   )
   (back (retrace))
)

; -----------------------------------------------------------------------------

(if (not #update-aweb)
   (
      (makedir @default-dest 
         (prompt #creating-dir @default-dest) 
      )
      (copyfiles
         (source (cat (pathonly @icon) ".info"))
         (dest (pathonly @default-dest))
         (newname "AWeb3SE.info")
         (prompt #creating-dir @default-dest)
         (noposition)
      )
   )
)
(complete 20)

(copyfiles
   (source "")
   (dest @default-dest)
   (choices "AWeb-II" "AWebCfg")
   (prompt #installing "AWeb")
   (infos)
)
(complete 40)

(copyfiles
   (source "")
   (dest @default-dest)
   (choices "aweblib")
   (prompt #installing "AWeb")
)

(copyfiles
   (source "")
   (dest @default-dest)
   (choices "AWebPlugin")
   (prompt #installing "AWeb")
   (infos)
)
(complete 50)

(copyfiles
   (source "")
   (dest @default-dest)
   (choices "ReadMe" "ATO.readme" "Docs" "Cache")
   (prompt #installing "AWeb")
   (infos)
)
(complete 60)

(copyfiles
   (source "")
   (dest @default-dest)
   (choices "Images" "Storage" "Install_Animation" "Install_Buttons")
   (prompt #installing "AWeb")
   (infos)
)
(complete 70)

(copyfiles
   (source "")
   (dest @default-dest)
   (choices "Plugins")
   (prompt #installing "Plugins")
   (infos)
)

(copylib
   (source "AWNPipe/awnpipe-handler")
   (dest "L:")
   (prompt #installing "Plugins")
)
(copyfiles
   (source "AWNPipe")
   (dest "Devs:DOSDrivers")
   (choices "AWNPipe")
   (prompt #installing "Plugins")
   (infos)
   (noposition)
)
(run "C:assign AWNPipe: dismount")
(run "C:mount AWNPipe:")
(complete 80)

; If any language calalogs are selected, copy them.

(if (bitand #languages 65534)
   (
      (set #catdir (tackon @default-dest "Catalogs"))
      (if (not (exists #catdir))
         (
            (makedir #catdir
               (prompt #creating-dir #catdir)
               (infos)
            )
            ; Hmm... (optional nofail) doesn't seem to work.
            (if (exists "Catalogs.info")
               (
                  (copyfiles
                     (source "Catalogs.info")
                     (dest @default-dest)
                     (prompt #creating-dir #catdir)
                     (optional nofail)
                  )
               )
            )
         )
      )
      (set #bit 2)    ; English implementation, so there is no catalog for it
      (set #langnr 1)
      (while (< #langnr 32)
         (if (bitand #languages #bit)
            (
               (set #lang
                  ; English is never selected from this list
                  (select #langnr "English" "Catal" "Czech" "Dansk" "Deutsch"
                     "Espaol" "Franais" "Hrvatski" "Italiano" "Magyar" "Nederlands" "Norsk"
                     "Polski" "Portugus" "Portugus-Brasil" "Russian"
                     "Slovensko" "Srpski" "Suomi" "Svenska" "Trke"
                  )
               )
               (if (exists (tackon "Catalogs" #lang))
                  (
                     (copyfiles
                        (source (tackon "Catalogs" #lang))
                        (choices "aweb.catalog" "awebcfg.catalog")
                        (dest (tackon #catdir #lang))
                     )
                  )
               )
            )
         )
         (set #bit (shiftleft #bit 1))
         (set #langnr (+ #langnr 1))
      )
   )
)

(complete 90)

(if (> #fonts 0)
   (
      (copyfiles
         (source "Fonts")
         (dest "Fonts:")
         (choices "times" "courier")
         (prompt #installing "fonts")
      )
      (run "SYS:System/FixFonts"
         (confirm)
         (prompt #fixfonts-prompt)
         (help #fixfonts-help)
      )
   )
)

(complete 100)

(message #picassowarning)
(run "SYS:Utilities/MultiView ReadMe" (prompt #readme))


(exit #bye (quiet))
