; IV24 Installation Script
; Version 1.08
; 8 March 1993
; Copyright 1993 by Great Valley Products, Inc.
;
; Written for use with Commodore's Installer tool
;
; set up IV24 vars
(set IV24  0)                                    ; bitnumber for askoptions call
(set iv_dsk "IV24_Install:")                     ; disk volume name
(set iv_vol "IV24_Install")                      ; paper label AND volname
(set iv_ug_dsk "IV24_Upgrade:")
(set iv_ug_vol "IV24_Upgrade")
(set fyelib (tackon iv_dsk "libs/fye.library"))  ; required IV24 library.
(set reqlib (tackon iv_dsk "libs/req.library"))  ; required library
(set iv_src (tackon iv_dsk "IV24"))              ; IV24 utilities structure
(set DD 1)
(set dd_src iv_dsk)

(set MyLAD 2)
(set ML_src iv_dsk)

; set up MacroPaint vars...        see start of MP section for destination
;                                  code (varies with drive selected)
(set MP    3)                      ; bitnumber for askoptions call
(set mp_src "MacroPaint2:")        ; MacroPaint volume name
(set mp_vol "MacroPaint2")         ; paper disk label and volume name (no colon)


(set Picts 4)
(set pic_dsk "IV24_Pictures")                ; Sample pictures disk label
(set pic_src "IV24_Pictures:")               ; (with colon)

; Common Vars
(set lib_dst "libs:")               ; libraries destination
(set dev_dst "devs:")               ; devices   destination
(set fnt_dst "fonts:")              ; fonts     destination
(set rx_dst  "rexx:")               ; destination for ARexx scripts
(set archiver "UNLZ")               ; de-archive utility
(set archPath (tackon iv_dsk "c"))  ; where archiver lives
(set archDest "ram:")               ; where to store copy of lharc
(set tempDest "ram:")               ; where libraries are extracted before copied.
(set look_here "")                  ; tell user where to look for s/w packages
(set os_ver
     (/ (getversion) $0000FFFF))    ; version of AmigaDOS...
(if (> 36 os_ver)                   ; Deal with DOS 1.3 IconX
        (set iconx_starter ".bra {\n.ket }\n")
        ; else
        (set iconx_starter "")
)

; Find out which packages to install
(set myopts (askoptions (prompt "Zu installierende Pakete"
            (help "\n"
                  "IV24 Utilities   - benötigte Libraries und verschiedene\n"
                  "                   nützliche Hilfsprogramme.\n"
                  "Desktop_Darkroom - Bildbearbeitungspaket.\n"
                  "myLAD            - Programm zum Überblenden.\n"
                  "MacroPaint2      - 24-bit Malprogramm.\n"             
                  "IV24 Pictures    - Beispielbilder bekannter\n"
                  "                   Künstler\n"
            )
            (choices "IV24 Utilities"
                     "Desktop_Darkroom"
                     "myLAD"
                     "MacroPaint2"
                     "IV24 Pictures")))
            ; Installer's default is all of the above
)

(set pkgs 0)                       ; How many packages will be installed?
                                   ; This info is used at Script's End...
(if (in myopts IV24)  (set pkgs (+ pkgs 1)))
(if (in myopts DD)    (set pkgs (+ pkgs 1)))
(if (in myopts MyLAD) (set pkgs (+ pkgs 1)))
(if (in myopts MP)    (set pkgs (+ pkgs 1)))
(if (in myopts Picts) (set pkgs (+ pkgs 1)))

; Place de-archiving utility in a convenient place.
(if (exists (tackon archPath archiver))
    (
        (working "Installation wird gestartet, bitte warten...")
        (run "copy " (tackon archPath archiver) " " archDest)
        (set archPath archDest)
    )
    ; else
    (set archPath "")     ; Checked elsewhere
)

(set destdir (askdir (prompt "Wo soll ich das Hauptverzeichnis für die IV24\n"
                             "erstellen?\n")
                        (help "Ein Verzeichnis mit dem Namen IV24 wird in dem von "
                              "Ihnen gewünschten Verzeichnis erstellt, und alle "
                              "Softwarepakete werden dort installiert.\n\n"
                              @askdir-help)
                        (newpath)
                        (default @default-dest))
)

(set maindest (tackon destdir "IV24"))

(if (NOT (exists maindest)) (
    (makedir maindest (prompt (cat "Erstelle" maindest))
             (infos) (help @makedir-help))
))

(set @default-dest maindest)
(set iv_dst @default-dest)       ; Destination for utils.
(set iv_def @default-dest)       ; default destination
(set iv_drv @default-dest)                       ; default dest. drive

; Percentage completion (very rough).
(complete 0)

;=========== Dearchive the libraries into RAM:

(if archPath
    (
      (working "Überprüfe Libraries...")
      (run (cat (tackon archPath archiver) " >nil: -mn x "
                (tackon iv_dsk "Libs.LZH") " "
                tempDest
           )
           (prompt "Entpacke und Libraries...")
      )
    )
)

;=========== Install all of the libraries, if they are newer.

; Install fye.library, if newer version.
(copylib (prompt "Soll ich fye.library installieren?")
         (help "Sie MÜSSEN diese Library installieren um jegliche "
               "IV24 Software zu betreiben!  \n\n Übergehen "
               "NUR wenn Sie eine neuere Version schon "
               "installiert haben."
         )
         (source (tackon tempDest "libs/fye.library"))
         (dest lib_dst)
         (confirm)
)

; Install req.library, if newer version.
(copylib (prompt "Soll ich die req.library installieren?")
         (help "Diese Library bietet einen File-Requestor "
               "und andere Merkmale für die IV24-Programme, "
               "und wird daher benötigt. \n\n"
               "Haben Sie noch keine req.library installiert, oder "
               "hat die Version auf der IV24 Install Disk eine größere "
               "Versionsnummer, so installieren Sie diese."
         )
         (source (tackon tempDest "libs/req.library"))
         (dest lib_dst) (confirm)
) ; copylib

; Install AmigaGuide.library, if newer version.
(copylib (prompt "Soll ich die amigaguide.library installieren?")
         (help "Sie MÜSSEN diese Library installieren um jegliche "
               "IV24 Software zu betreiben!  \n\nÜbergehen "
               "NUR wenn Sie eine neuere Version schon "
               "installiert haben."
         )
         (source (tackon tempDest "libs/amigaguide.library"))
         (dest lib_dst)
         (confirm)
)

; Install dctv.library, if newer version.
(copylib (prompt "Soll ich die  dctv.library installieren?")
         (help "Sie MÜSSEN diese Library installieren um jegliche "
               "IV24 Software zu betreiben!  \n\nÜbergehen "
               "NUR wenn Sie eine neuere Version schon"
               "installiert haben. "
         )
 
         (source (tackon tempDest "libs/dctv.library"))
         (dest lib_dst)
         (confirm)
)

; Install hame.library, if newer version.
(copylib (prompt "Soll ich die hame.library installieren?")
         (help "Sie MÜSSEN diese Library installieren um jegliche "
               "IV24 Software zu betreiben!  \n\nÜbergehen "
               "NUR wenn Sie eine neuere Version schon"
               "installiert haben. "
         )

         (source (tackon tempDest "libs/hame.library"))
         (dest lib_dst)
         (confirm)
)

; Install renderhame.library, if newer version.
(copylib (prompt "Shall I install renderhame.library?")
         (help "Sie MÜSSEN diese Library installieren um jegliche "
               "IV24 Software zu betreiben!  \n\nÜbergehen "
               "NUR wenn Sie eine neuere Version schon"
               "installiert haben. "
         )
         (source (tackon tempDest "libs/renderhame.library"))
         (dest lib_dst)
         (confirm)
)

; Install iff.library, if newer version.
(copylib (prompt "Soll ich die iff.library installieren?")
         (help "Sie MÜSSEN diese Library installieren um jegliche "
               "IV24 Software zu betreiben!  \n\nÜbergehen "
               "NUR wenn Sie eine neuere Version schon "
               "installiert haben."
         )
         (source (tackon tempDest "libs/iff.library"))
         (dest lib_dst)
         (confirm)
)

; Install gvpi.library, if newer version.
(copylib (prompt "Soll ich die gvpi.library installieren?")
         (help "Sie MÜSSEN diese Library installieren um jegliche "
               "IV24 Software zu betreiben!  \n\nÜbergehen "
               "NUR wenn Sie eine neuere Version schon "
               "installiert haben."
         )
         (source (tackon tempDest "libs/gvpi.library"))
         (dest lib_dst)
         (confirm)
)

;========= Remove the temporary libraries in RAM:
; not working... might have to go to something stronger...

(delete (tackon tempDest "libs"))


(working "\n\n\n"
         "Während ich die IV24 Utilities installiere, können "
         "Sie sich die Zeit nehmen und Ihre Registraturkarte "
         "ausfüllen !")

; IV24 Required Utilities ======================================================
(if (in myopts IV24)
  (
    ; Find out where to install IV24 general utilities.
    
        (run (cat (tackon archPath archiver) " >nil: -mn x "
           (tackon iv_dsk "IVUtils.LZH") " "
           iv_dst "/")
        )


    ; Add IV24 tool location to path...
    ; First, give advanced and average users the chance to confirm
    ; this.  Average users aren't asked by (startup).  Advanced ones
    ; are, but might run into trouble due to V1.6 Installer's problems
    ; in dealing with heavily-modified startups.  This gives a chance
    ; to dodge in such cases.
    (set mods_ok TRUE)
    (if (>= @user-level 1)
        (set mods_ok
            (askbool (help "Wenn Sie mit 'Ja' antworten, heißt "
                      "das, es ist okay für den Installer die  "
                      "startup Prozedur (s:user-startup oder "
                      "s:startup-sequence ), sodaß die Software "
                      "der IV24 bequemer zu bedienen ist.\n "
                      "In diesem Fall werden die folgenden Zeilen "
                      "hinzugefügt:\n"
                      "if  exists \"" iv_dst "/IVUtils\"\n"
                      "path \"" iv_dst "/IVUtils\" add\n"
                      "endif\n\n"
                      "Es ist sehr vorteilhaft: wenn das Verzeichnis"
                      "in Ihrem Pfad ist, Sie müssen nicht den ganzen "
                      "Kommandopfad von der Shell eintippen; unter "
                      "AmigaDOS 2.0, Sie müssen nicht den ganzen "
                      "Pfad in Ihr Workbench Piktogramm eintippen.")
                     (prompt "Dürfen ein paar Zeilen am Ende Ihrer Startup"
                             "Prozedur eingefügt werden, damit die IV24"
                             "Software im aktuellen Pfad verfügbar ist?"
                             "Drücken Sie Hilfe für mehr Details.")
                     (default 1)
    )   )   )

    ; Actually change the startup, if user said OK.  Advanced users
    ; will okay it here.
    (if mods_ok
      (
        (onerror
            (message "Es tut uns leid, aber Ihre Startup-sequence fehlt "
                 "oder ist zu sehr verändert, das Installer Program kann "
                 "die entsprechenden Zeilen nicht einfügen. Starten Sie "
                 "Install erneut, und wählen nicht diese Option.\n\n"
                 "Es können diese Kommandos auch automatisch "
                 "ausgeführt werden indem Sie in s:Startup-Sequence oder "
                 "s:User-startup, je nach System die Zeilen einfügen.  "
                 "Beachten Sie, daß wenn Sie die Datei s:User-Startup, "
                 "benutzen, diese auch von s:startup-sequence aus "
                 "aufgerufen werden muß.\n")
        )
        ; Only Advanced Users will see this Prompt...they will have seen
        ; the previous one, too.  Make this one innocuous.
        (startup "IV24 Tools"
                 (prompt "Drücken Sie 'Weiter' um den Startup zu "
                         "verändern damit '" iv_dst "/IVUtils' zu Ihrem "
                         "Pfad angehängt wird.\n")
                 (help "Es ist sehr vorteilhaft: wenn das Verzeichnis"
                      "in Ihrem Pfad ist, Sie müssen nicht den ganzen "
                      "Kommandopfad von der Shell eintippen; unter "
                      "AmigaDOS 2.0, Sie müssen nicht den ganzen "
                      "Pfad in Ihr Workbench Piktogramm eintippen.\n\n"
                       "Beachten Sie, daß der Installer jede existierende "
                       "Referenz ändert, solange der Installer diese auch "
                       "erstellt hat.\n"
                       "Folgende Zeilen werden eingefügt:\n\n"
                       "  if  exists \"" iv_dst "/IVUtils\"\n"
                       "  path \"" iv_dst "/IVUtils\" add\n"
                       "  endif\n" )
                 (command  "if  exists \"" iv_dst "/IVUtils\"\n"
                           "path \"" iv_dst "/IVUtils\" add\n"
                           "endif\n")
        )
      ) ;endtrue
    ) ;endif

  ) ; END of TRUE for IV24 Main Loop

  ; else

  (set look_iv24 "")  ; for end-of-script, user-info-msg purposes
)

(complete (/ 100 6))

; DesktopDarkroom ==========================================

(if (in myopts DD)
  (
    (working "Entpacke and installiere Desktop Darkroom\n"
             "into \""
             (tackon @default-dest "Desktop_Darkroom")
             "\"")
    
    (if archPath
        (run (cat (tackon archPath archiver) " >nil: -mn x "
           (tackon dd_src "Desktop.LZH") " "
           @default-dest "/")
           (prompt "Entpacken...")
        )
    )
  ) 
)

(complete (/ 100 5))

; MyLAD ====================================================

(if (in myopts MyLAD)
  (
    (working "Entpacke und installiere myLAD\n"
             "into \""
             (tackon @default-dest "myLAD")
             "\"")
    
    (if archPath
        (run (cat (tackon archPath archiver) " >nil: -mn x "
           (tackon ML_src "MyLAD.LZH") " "
           @default-dest "/")
           (prompt "Entpacken...")
        )
    )
  )
)

(complete (/ 100 4))

; MacroPaint ===================================================================

(if (in myopts MP)
  (
    ; Default dest is where to put this carp.
    (set mp_def (tackon @default-dest "MacroPaint2"))

    ; Get destination directory for MacroPaint materials.
    (set mp_dst mp_def)
    
    ; Make dest dir if needed
    (if (NOT (exists mp_dst)) (
        (makedir mp_dst (prompt (cat "Erstelle" mp_dst))
                 (infos) (help @makedir-help))
    ))

    ; Ask for MacroPaint disk
    (askdisk   (prompt "Bitte legen Sie ein:\n"
                       "Diskette #2, \n'" mp_vol "'")
               (dest mp_vol)
               (help @askdisk-help))

    ; Install appropriate MP files
    
    (copyfiles
            (prompt "Installiere MacroPaint2 ")
            (help @copyfiles-help)
            (source mp_src)
            (dest mp_dst)
            (pattern "ReadMe.MP#?")
            (files)
            (infos)
            (confirm)
    )
    
    (working "Entpacke und installiere MacroPaint2...")
    
    (if archPath
      (
        (run (cat (tackon archPath archiver) " >nil: -mn x "
           (tackon mp_src "MacroPaint.LZH") " "
           mp_dst "/")
           (prompt "Entpacke...")
        )
        
        (run (cat (tackon archPath archiver) " >nil: -mn x "
           (tackon mp_src "Images.LZH") " "
           mp_dst "/")
           (prompt "Entpacke...")
        )
        
        (working "Entpacke und installiere Pinsel...")
        
        (run (cat (tackon archPath archiver) " >nil: -mn x "
           (tackon mp_src "Brushes.LZH") " "
           mp_dst "/")
           (prompt "Entpacke...")
        )
        
        (run (cat (tackon archPath archiver) " >nil: -mn x "
           (tackon mp_src "Palettes.LZH") " "
           mp_dst "/")
           (prompt "Entpacke...")
        )
      )
    )

     ; Conditionally install ARexx programs.
     
     (if (askbool (prompt "Wollen Sie die ARexx Skripts für MacroPaint installieren?")
                  (help "Besitzen Sie die ARexx Programmiersprache, so "
                        "können Sie diese Skripts in MacroPaint nutzen.  "
                        "ARexx als Bestandteil von AmigaDOS 2.0 verfügbar, "
                        "oder von Wishful Thinking Development Corp.\n\n"
                        "Haben Sie ARexx oder bekommen Sie ARexx, ist es "
                        "sinnvoll diese Skripts zu installieren.\n\n"
                        mp_rxhelp
                  )
                  (default "Ja")
                  (choices "Ja" "Nein"))
         (
          (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mn x "
                      (tackon mp_src "Rexx.LZH") " "
                      mp_dst "/")
                 (prompt "Entpacke...")
            )
          )
         ) ; end true
    ) ; end if askbool

    ; Conditionally install 24-bit images.
    (if (askbool (prompt "Wollen Sie die 24-bit Bilder laden?")
                 (help " Es werden zwei 24-bit JPEG-Bilder geladen\n\n"
                       " Sie werden für das Tutorial benötigt."
                 )
                 (default "Ja")
                 (choices "Ja" "Nein"))
      (
      ; Unpack Archived Images (MacroPaint >= 1.56)
        ; display 'busy' message.
        (working "\nEntpacke Archiv von 24-bit Bildern...\n")
        
        ; Unpack using appropriate archiver.  Remember to quote destination.
        (if archPath
            (run (cat (tackon archPath archiver) " >nil: -mn x "
                 (tackon mp_src "Pictures.LZH") " "
                 mp_dst "/"))
        )
      ) ; end true (if askbool)
    ) ; end (if askbool)
    (set look_mp mp_dst)  ; for end-of-script, user-info-msg purposes

  ) ; end TRUE part of (if Macropaint)

    ;else

  (set look_mp "")  ; for end-of-script, user-info-msg purposes
)   ; END whether to install MacroPaint

(complete (/ 200 6))


; Sample 24-bit pictures ==============================================

(if (in myopts Picts)
  (
   (complete 75)
    (askdisk   (prompt "Bitte legen Sie ein:\n"
                       "Diskette #3, \n'" pic_dsk "'")
               (dest pic_dsk)
               (help @askdisk-help)
    )
    
    ; Default dest is where to put this crap.
    (set pic_def (tackon @default-dest "Pictures"))


    ; Get destination directory for sample pictures.
    (set pic_dst pic_def)
    
    
    ; Make dest dir if needed
    (if (NOT (exists pic_dst)) (
        (makedir pic_dst (prompt (cat "Erstelle" pic_dst))
                 (infos) (help @makedir-help))
    ))
    
    (if archPath
     (
      (working "Kopiere digitalisierte Beispielbilder ...")
      
      (run (cat (tackon archPath archiver) " >nil: -mn x "
                (tackon pic_src "Grabbed.LZH") " "
                pic_dst "/"
           )
           (prompt "Entpacke...")
      )
      
      (working "Kopiere gemalte Beispielbilder...")
      
      (run (cat (tackon archPath archiver) " >nil: -mn x "
                (tackon pic_src "Painted.LZH") " "
                pic_dst "/"
           )
           (prompt "Entpacke...")
      )
      
      (working "\n\n\n"
               "Während die gerenderten Beispielbilder kopiert werden "
               "können Sie schonmal die Registraturkarte zum Abschicken "
               "bereitmachen.")
      
      (run (cat (tackon archPath archiver) " >nil: -mn x "
                (tackon pic_src "Rendered.LZH") " "
                pic_dst "/"
           )
           (prompt "Entpacke...")
      )
     )
    )
  )
)
(complete 100)


; Remove temporary assign file.


; If our archiver wound up in ram:, delete it.
(if (exists (tackon archDest archiver))
        (delete (tackon archDest archiver)
                (prompt "Lösche temporäre Dateien in " archDest ".")
                (help @delete-help)))

(exit 
      "\n"
      "Bitte starten Sie Ihren Rechner jetzt neu um die Libraries und "
      "die Software zu benutzen die Sie installiert haben.\n\n\n"
      "Vergessen Sie nicht, Ihre Registraturkarte abzuschicken!")
