; $VER: Install_awebjfif_awebplugin
; Description: Installer script for the "awebjfif" plugin for AWeb 3.0+

(set #welcome
   (cat "This installation procedure will install the \"awebjfif\" plugin module for AWeb version 3.0 or higher.\n"
        "\n"
        "This plugin enables you to view JFIF (JPEG) images in AWeb without the use of datatypes. The plugin has the following features:\n"
        "Optional progressive display\n"
        "Support for image scaling\n"
        "Support for CyberGraphics\n"
   )
)

(set #no-AWeb_APL
   (cat "The \"AWeb_APL:\" assign was not found.\n\n"
        "This plugin can only be used with AWeb version 3.0 or higher."
   )
)

(set #swap-prompt
   "Select a directory for temporary swap files. See HELP for more info."
)

(set #swap-help
   (cat "During the decoding of large images, a lot of memory may be required. "
        "To save actual memory usage for those large images, parts of the "
        "decoder's working memory may be swapped out to your hard disk.\n\n"
        "You should select a directory on your hard disk where these temporary "
        "files may be stored.\n\n"
   )
)

(set #show-docs
   (cat "All necessary files have been copied. "
      "To use the plugin, you have to do some additional setup. "
      "This is described in the documentation. "
      "From the documentation, you can run the setup script that performs the additional setup automatically. "
      "\n"
      "Do you want to view the documentation now?\n"
   )
)

(set #startup-prompt "Adding the command\n\n%s\n\nto your S:User-Startup")

(set #startup-help
   (cat "During the decoding of large images, a lot of memory may be required. "
        "To save actual memory usage for those large images, parts of the "
        "decoder's working memory may be swapped out to your hard disk.\n\n"
        "This assign will allow these temporary files to be stored in the %s drawer.\n\n"
   )
)

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

(complete 0)

(message #welcome)

(if (not (exists "AWeb_APL:"))
   (abort #no-AWeb_APL)
)

(complete 10)

(if (not (exists "AWeb_APL:awebplugin"))
   (makedir "AWeb_APL:awebplugin"
      (infos)
   )
)

(set srcdir (pathonly @icon))

(copyfiles
   (source (tackon srcdir "awebjfif.awebplugin"))
   (dest "AWeb_APL:awebplugin")
   (infos)
)

(complete 40)

(if (not (exists "AWeb_APL:awebplugin/Docs"))
   (makedir "AWeb_APL:awebplugin/Docs"
      (infos)
   )
)

(copyfiles
   (source srcdir)
   (choices "awebjfif.html" "awebjfif.awebrx")
   (dest "AWeb_APL:awebplugin/Docs")
   (infos)
)

(complete 70)

(if (not (exists "JPEGTMP:" (noreq)))
   (
      (set #defaultswap "Work:")

      ; Make sure the next question is always asked even in beginner mode
      (if (< @user-level 1)
         (set #olduser (user 1))
         ;else
         (set #olduser @user-level)
      )

      (set #swapdir
         (askdir
            (prompt #swap-prompt)
            (help (cat #swap-help @askdir-help))
            (disk)
            (default #defaultswap)
         )
      )

      (user #olduser)

      (set #assign (cat "Assign JPEGTMP: " #swapdir))

      (complete 80)

      (startup "AWebJFIF"
         (prompt (#startup-prompt #assign))
         (help (cat (#startup-help #swapdir) @startup-help))
         (command #assign)
      )

      (makeassign "JPEGTMP" #swapdir)
   )
)

(complete 90)

(if
   (askbool
      (prompt #show-docs)
      (help #show-docs)
      (default 1)
   )
   (
      (run "run AWeb_APL:AWeb file:///AWeb_APL:awebplugin/Docs/awebjfif.html")
   )
)

(set @default-dest (expandpath "AWeb_APL:awebplugin"))

(complete 100)
