; This is the ScanQuix3 install script

; 1.0 -> 1.1 : - Installation von AdPro- und PageStream Lademodulen hinzugefügt
; 1.1 -> 1.2 : - Installation von DPaintV Lademodul hizugefügt
;              - Bei AdPro und Pagestream copylib durch copyfiles ersetzt
; 1.2 -> 1.3 : - Bei Photogenics wird der GIO-Catalog nur noch kopiert, wenn
;                "Photogenics:" existiert.
; 1.3 -> 1.4 : - Installation von ArtEffect Plugin hinzugefügt
;              - Photogenics: GIO-Catalog wird bei deinstallation jetzt auch gelöscht.

(transcript "ScanQuix installation:")

(if (patmatch @language "deutsch")
  (set deutsch 1)
  (set deutsch 0)
)

(if deutsch
  (set t_welche_op "\n\n\n\nBitte wählen Sie, welche Aktion durchgeführt werden soll:")
  (set t_welche_op "\n\n\n\nWhat Operation do you want to perform ?")
)
(if deutsch
  (set t_welcheop_help "\"ScanQuix installieren\" installiert die komplette ScanQuix Software.\n\"Installation entfernen\" löscht die gesamte ScanQuix-Installation von Ihrer Festplatte.")
  (set t_welcheop_help "By choosing \"Install ScanQuix\", you can install ScanQuix and the scanner driver(s) on your computer.\nWith the choice \"Remove Installation\", an existing installation of ScanQuix and the scanner drivers can be entirely removed from your System.")
)
(if deutsch
  (set t_welheop_1 "ScanQuix installieren")
  (set t_welheop_1 "Install ScanQuix")
)
(if deutsch
  (set t_welheop_0 "Installation entfernen")
  (set t_welheop_0 "Remove ScanQuix")
)
(if deutsch
  (set t_woanlegen "Wo soll die ScanQuix Schublade eingerichtet werden ?")
  (set t_woanlegen "Where do you want the \"ScanQuix\" drawer to be created ?")
)
(if deutsch
  (set t_copying_sq "\n\n\nScanQuix wird kopiert...")
  (set t_copying_sq "\n\n\nCopying ScanQuix...")
)
(if deutsch
  (set t_copying_gtlib "\n\n\nDie gtlayout.library wird kopiert...")
  (set t_copying_gtlib "\n\n\nCopying gtlayout.library...")
)
(if deutsch
  (set t_copying_device "\n\n\nDas scanner.device wird kopiert...")
  (set t_copying_device "\n\n\nCopying scanner.device...")
)
(if deutsch
  (set t_copying_driver "\n\n\nDer Scanner-Treiber wird kopiert...")
  (set t_copying_driver "\n\n\nCopying scanner driver...")
)
(if deutsch
  (set t_copying_cat_d "\n\n\nDie deutschen Programmtexte werden kopiert...")
  (set t_copying_cat_d "\n\n\nCopying german catalog files...")
)
(if deutsch
  (set t_copying_cat_f "\n\n\nDie französischen Programmtexte werden kopiert...")
  (set t_copying_cat_f "\n\n\nCopying french catalog files...")
)
(if deutsch
  (set t_askloader "Welche Lademodule sollen installiert werden ?")
  (set t_askloader "Which loaders do you want to be installed ?")
)
(if deutsch
  (set t_copying_GIO "\n\n\nDas Lademodul für Photogenics wird kopiert...")
  (set t_copying_GIO "\n\n\nCopying Photogenics loader...")
)
(if deutsch
  (set t_copying_IFX "\n\n\nDas Scannermodule für ImageFX  wird kopiert...")
  (set t_copying_IFX "\n\n\nCopying ImageFX scanner module...")
)
(if deutsch
  (set t_copying_ADPRO "\n\n\nDas Scannermodule für ADPro  wird kopiert...")
  (set t_copying_ADPRO "\n\n\nCopying ADPro scanner module...")
)
(if deutsch
  (set t_copying_PGS "\n\n\nDas Scannermodule für PageStream 3 wird kopiert...")
  (set t_copying_PGS "\n\n\nCopying PageStream 3 scanner module...")
)
(if deutsch
  (set t_copying_DPV "\n\n\nDas Scannermodule für Deluxe Paint V wird kopiert...")
  (set t_copying_DPV "\n\n\nCopying Deluxe Paint V scanner module...")
)
(if deutsch
  (set t_copying_PSS "\n\n\nDas Plugin für ArtEffect wird kopiert...")
  (set t_copying_PSS "\n\n\nCopying plugin for ArtEffect...")
)
(if deutsch
  (set t_copying_PP "\n\n\nDas PPaint Lademodul wird kopiert...")
  (set t_copying_PP "\n\n\nCopying PPaint loader...")
)
(if deutsch
  (set t_wirklich_loeschen "\n\n\n\nMöchten Sie wirklich die gesamte ScanQuix Installation\nentfernen ?\n\nAlle Einstellungen werden dabei gelöscht !\nALLE BILDER im ScanQuix-Verzeichnis WERDEN UNWIEDERBRINGLICH GELÖSCHT !")
  (set t_wirklich_loeschen "\n\n\n\nDo you really want to remove your ScanQuix installation ?\n\nAll settings will be lost !\nALL IMAGES in the ScanQuix drawer ARE DELETED !")
)
(if deutsch
  (set t_loeschen_help "Sie könenn die Scannertreiber jederzeit neu installieren, allerdings sind die Einstellungen verloren !")
  (set t_loeschen_help "You can reinstall your scanner drivers at any time, but you will loose the current settings !")
)
(if deutsch
  (set t_loesche_sq "Die ScanQuix Installation wird gelöscht.")
  (set t_loesche_sq "Deleting the ScanQuix installation.")
)
(if deutsch
  (set t_makedir "Verzeichnis wird erstellt...")
  (set t_makedir "Creating directory...")
)
(if deutsch
  (set t_save_dest "Pfad des ScanQuix-Verzeichnisses wird gespeichert...")
  (set t_save_dest "Saving path of ScanQuix drawer...")
)
(if deutsch
  (set t_savedesthelp "Der Pfad wird im ENV: Verzeichnis gespeichert, um die ScanQuix-Installation ggf. vollständig entfernen zu können.")
  (set t_savedesthelp "The Path is saved to the ENV: directory. This is important to uninstall the ScanQuix software.")
)
(if deutsch
  (set t_zeige_piktos "Piktogramme werden gezeigt...")
  (set t_zeige_piktos "Icons are displayed...")
)
(if deutsch
  (set t_anzeigen_help "Das Programm MultiView wird gestartet, um die zur Verfügung stehenden Piktogramme anzuzeigen.")
  (set t_anzeigen_help "The program MultiView is started to show you the icons which can be installed.")
)
(if deutsch
  (set t_askicon "Welche Piktogramme möchten Sie für ScanQuix installieren ?")
  (set t_askicon "Which icons do you want to install for ScanQuix ?")
)
(if deutsch
  (set t_copying_icons "Piktogramme werden installiert.")
  (set t_copying_icons "Installing Icons.")
)
;(if deutsch
;  (set t_ "")
;  (set t_ "")
;)


(set install_sq
  (askbool
    (prompt t_welche_op)
    (help t_welcheop_help)
    (choices t_welheop_1 t_welheop_0)
    (default 1)
  )
)

(if install_sq
 (
  (set sq_path
    (askdir
      (prompt t_woanlegen)
      (help @askdir-help)
      (default @default-dest)
    )
  )

  (set @default-dest sq_path)

  (copyfiles
    (prompt t_copying_sq)
    (help @copyfiles-help)
    (source "ScanQuix3:ScanQuix3")
    (dest (tackon sq_path "ScanQuix3"))
    (all)
    (infos)
    (confirm)
  )

  (if deutsch
    (makedir (tackon sq_path "ScanQuix3/Bilder") 
      (prompt t_makedir)
      (help @makedir-help)
      (infos)
    )
    (makedir (tackon sq_path "ScanQuix3/Pictures")
      (prompt t_makedir)
      (help @makedir-help)
      (infos)
    )
  )

;  (if 0 (<> @user-level 0)
;    (
;      (run "run >NIL: MultiView ScanQuix3:Icons/Icons.iff"
;        (prompt t_zeige_piktos)
;        (help t_anzeigen_help)
;        (confirm)
;      )
;  
;      (set icon_set (askchoice
;        (prompt t_askicon)
;        (help @askchoice-help)
;        (choices "(a) Scanner" "(b) Auge")
;        (default 0)
;    )
;
;    (if (in icon_set 0)
;      (copyfiles 
;        (prompt t_copying_icons)
;        (help @copyfiles-help)
;        (source "ScanQuix3:Icons/a")
;        (dest (tackon sq_path "ScanQuix3"))
;        (all)
;        (confirm)
;      )
;    )
;
;    (if (in icon_set 1)
;      (copyfiles 
;        (prompt t_copying_icons)
;        (help @copyfiles-help)
;        (source "ScanQuix3:Icons/b")
;        (dest (tackon sq_path "ScanQuix3"))
;        (all)
;        (confirm)
;      )
;    )
;  )

  (copylib
    (prompt t_copying_gtlib)
    (help @copylib-help)
    (source "ScanQuix3:Libs/gtlayout.library")
    (dest "LIBS:")
    (confirm)
  )

  (copylib
    (prompt t_copying_device)
    (help @copylib-help)
    (source "ScanQuix3:Devs/scanner.device")
    (dest "DEVS:")
    (confirm)
  )

  (copyfiles
    (prompt t_copying_driver)
    (help @copyfiles-help)
    (source "ScanQuix3:Devs/Scanners")
    (dest "DEVS:Scanners")
    (all)
    (infos)
    (confirm)
  )

  (if (exists "LOCALE:" (noreq))
    (
     ; locale is installed, so copy the catalog stuff
      (if (exists "LOCALE:Catalogs/deutsch" (noreq))
        (copyfiles
    	    (prompt t_copying_cat_d)
          (help @copyfiles-help)
          (source "ScanQuix3:Catalogs/deutsch/")
          (dest "LOCALE:Catalogs/deutsch/ScanQuix")
          (confirm)
          (all)
        )
      )

;      (if (exists "LOCALE:Catalogs/français" (noreq))
;        (copyfiles
;    	    (prompt t_copying_cat_f)
;          (help @copyfiles-help)
;          (source "ScanQuix3:Catalogs/français/ScanQuix")
;          (dest "LOCALE:Catalogs/français/ScanQuix")
;          (confirm)
;          (all)
;        )
;      )
    )
  )

  (makedir "ENVARC:ScanQuix"
    (prompt t_makedir)
    (help @makedir-help)
    (infos)
  )

  (makedir "ENVARC:ScanQuix/Scanners"
    (prompt t_makedir)
    (help @makedir-help)
    (infos)
  )

  (makedir "ENV:ScanQuix"
    (prompt t_makedir)
    (help @makedir-help)
    (infos)
  )

  (makedir "ENV:ScanQuix/Scanners"
    (prompt t_makedir)
    (help @makedir-help)
    (infos)
  )

  (textfile
    (prompt t_save_dest)
    (help t_savedesthelp)
    (dest "ENVARC:ScanQuix/Path")
    (append sq_path)
  )

  (textfile
    (prompt t_save_dest)
    (help t_savedesthelp)
    (dest "ENV:ScanQuix/Path")
    (append sq_path)
  )


  (set loader (askoptions
    (prompt t_askloader)
    (help @askoptions-help)
    (choices "Photogenics" "ImageFX" "Art Department Prof." "PageStream 3" "Deluxe Paint V" "ArtEffect" "PPaint")
    (default -1)
  ))

  (if (in loader 0)
    (if (exists "Photogenics:" (noreq))
      (
        (copylib
          (prompt t_copying_GIO)
          (help @copylib-help)
          (source "ScanQuix3:Support/Photogenics/ScanQuix.gio")
          (dest "Photogenics:Data/GIO")
          (confirm)
        )

        (if (exists "LOCALE:Catalogs/deutsch" (noreq))
          (copyfiles
    	      (prompt t_copying_cat_d)
            (help @copyfiles-help)
            (source "ScanQuix3:Support/Photogenics/deutsch/ScanQuix_GIO.catalog")
            (dest "LOCALE:Catalogs/deutsch")
            (confirm)
          )
        )
      )
    )
  )

  (if (in loader 1)
    (if (exists "ImageFX:" (noreq))
      (copylib
        (prompt t_copying_IFX)
        (help @copylib-help)
        (source "ScanQuix3:Support/ImageFX/ScanQuix")
        (dest "ImageFX:Modules/Scanner")
        (confirm)
      )
    )
  )

  (if (in loader 2)
    (if (exists "ADPRO:" (noreq))
      (copyfiles
        (prompt t_copying_ADPRO)
        (help @copyfiles-help)
        (source "ScanQuix3:Support/ADPro/SCANQUIX")
        (dest "ADPRO:Loaders2")
        (confirm)
      )
    )
  )

  (if (in loader 3)
    (if (exists "PageStream3:" (noreq))
      (copyfiles
        (prompt t_copying_PGS)
        (help @copyfiles-help)
        (source "ScanQuix3:Support/PageStream/ScanImage.rexx")
        (dest "PageStream3:Macros")
        (confirm)
      )
    )
  )

  (if (in loader 4)
    (if (exists "DPaintV:" (noreq))
      (copyfiles
        (prompt t_copying_DPV)
        (help @copyfiles-help)
        (source "ScanQuix3:Support/DPaintV")
        (dest "DPaintV:Macros")
        (confirm)
        (all)
      )
    )
  )

  (if (in loader 5)
    (if (exists "ArtEffect:" (noreq))
      (
        (copyfiles
          (prompt t_copying_PSS)
          (help @copyfiles-help)
          (source "ScanQuix3:Support/ArtEffect/ScanQuix.pss")
          (dest "ArtEffect:plugins")
          (confirm)
        )

        (if (exists "LOCALE:Catalogs/deutsch" (noreq))
          (copyfiles
    	      (prompt t_copying_cat_d)
            (help @copyfiles-help)
            (source "ScanQuix3:Support/ArtEffect/deutsch/ScanQuix_PSS.catalog")
            (dest "LOCALE:Catalogs/deutsch")
            (confirm)
          )
        )
      )
    )
  )

  (if (in loader 6)
    (if (exists "PPaint:Libs" (noreq))
      (copyfiles
        (prompt t_copying_PP)
        (help @copyfiles-help)
        (source "ScanQuix3:Support/PPaint")
        (dest "PPaint:Libs")
        (confirm)
        (all)
      )
    )
  )

;  (set old_user (user 1))   ; always ask
;  (user old_user)

 )
 (  ; else uninstall

  (set @default-dest "")

  (if (askbool
        (prompt t_wirklich_loeschen)
        (help t_loeschen_help)
        (default 0)
      )

    (
     ; uninstall procedure

      (if (exists "ENV:ScanQuix/Path")
        (
          (run (cat "delete \"" (tackon (getenv "ScanQuix/Path") "ScanQuix3\"") "all")
            (prompt t_loesche_sq)
            (help t_loeschen_help)
            (confirm)
          )

          (run (cat "delete \"" (tackon (getenv "ScanQuix/Path") "ScanQuix3.info\""))
            (prompt t_loesche_sq)
            (help t_loeschen_help)
            (confirm)
          )
        )
      )

      (run "delete DEVS:Scanners all"
        (prompt t_loesche_sq)
        (help t_loeschen_help)
        (confirm)
      )

      (delete "DEVS:Scanners.info"
        (prompt t_loesche_sq)
        (help t_loeschen_help)
        (confirm)
      )

      (delete "DEVS:scanner.device"
        (prompt t_loesche_sq)
        (help t_loeschen_help)
        (confirm)
      )

      (if (exists "Photogenics:" (noreq))
        (
          (delete "Photogenics:Data/GIO/ScanQuix.gio"
            (prompt t_loesche_sq)
            (help t_loeschen_help)
            (confirm)
          )
          (delete "LOCALE:Catalogs/deutsch/ScanQuix_GIO.catalog"
            (prompt t_loesche_sq)
            (help t_loeschen_help)
            (confirm)
          )
        )
      )

      (if (exists "ImageFX:" (noreq))
        (delete "ImageFX:Modules/Scanner/ScanQuix"
          (prompt t_loesche_sq)
          (help t_loeschen_help)
          (confirm)
        )
      )

      (if (exists "ADPRO:" (noreq))
        (delete "ADPRO:Loaders2/SCANQUIX"
          (prompt t_loesche_sq)
          (help t_loeschen_help)
          (confirm)
        )
      )

      (if (exists "PageStream3:" (noreq))
        (delete "PageStream3:Macros/ScanImage.rexx"
          (prompt t_loesche_sq)
          (help t_loeschen_help)
          (confirm)
        )
      )

      (if (exists "DPaintV:" (noreq))
        (delete "DPaintV:Macros/Scan(Image|Brush).dprx"
          (prompt t_loesche_sq)
          (help t_loeschen_help)
          (confirm)
        )
      )

      (if (exists "PPaint:Libs" (noreq))
        (delete "PPaint:Libs/personal_scanquix_io.library"
          (prompt t_loesche_sq)
          (help t_loeschen_help)
          (confirm)
        )
      )

      (if (exists "ArtEffect:" (noreq))
        (
          (delete "ArtEffect:plugins/ScanQuix.pss"
            (prompt t_loesche_sq)
            (help t_loeschen_help)
            (confirm)
          )
          (delete "LOCALE:Catalogs/deutsch/ScanQuix_PSS.catalog"
            (prompt t_loesche_sq)
            (help t_loeschen_help)
            (confirm)
          )
        )
      )

      (delete "DEVS:scanner.device"
        (prompt t_loesche_sq)
        (help t_loeschen_help)
        (confirm)
      )

      (run "delete LOCALE:Catalogs/deutsch/ScanQuix all"
        (prompt t_loesche_sq)
        (help t_loeschen_help)
        (confirm)
      )

      (run "delete ENVARC:ScanQuix all"
        (prompt t_loesche_sq)
        (help t_loeschen_help)
        (confirm)
      )

      (run "delete ENV:ScanQuix all"
        (prompt t_loesche_sq)
        (help t_loeschen_help)
        (confirm)
      )

    )
  )
 )
)
